提交 59e97327 编写于 作者: M Masakazu Mokuno 提交者: Jeff Garzik

PS3: gelic: code cleanup

Code cleanup:
 - Use appropriate prefixes for names instead of fixed 'gelic_net'
   so that objects of the functions, variables and constants can be estimated.
 - Remove definitions for IPSec offload to the gelic hardware.  This
   functionality is never supported on PS3.
 - Group constants with enum.
 - Use bitwise constants for interrupt status, instead of bit numbers to
   eliminate shift operations.
 - Style fixes.
Signed-off-by: NMasakazu Mokuno <mokuno@sm.sony.co.jp>
Signed-off-by: NJeff Garzik <jeff@garzik.org>
上级 100e1d89
...@@ -54,21 +54,21 @@ MODULE_AUTHOR("SCE Inc."); ...@@ -54,21 +54,21 @@ MODULE_AUTHOR("SCE Inc.");
MODULE_DESCRIPTION("Gelic Network driver"); MODULE_DESCRIPTION("Gelic Network driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static inline struct device *ctodev(struct gelic_net_card *card) static inline struct device *ctodev(struct gelic_card *card)
{ {
return &card->dev->core; return &card->dev->core;
} }
static inline u64 bus_id(struct gelic_net_card *card) static inline u64 bus_id(struct gelic_card *card)
{ {
return card->dev->bus_id; return card->dev->bus_id;
} }
static inline u64 dev_id(struct gelic_net_card *card) static inline u64 dev_id(struct gelic_card *card)
{ {
return card->dev->dev_id; return card->dev->dev_id;
} }
/* set irq_mask */ /* set irq_mask */
static int gelic_net_set_irq_mask(struct gelic_net_card *card, u64 mask) static int gelic_card_set_irq_mask(struct gelic_card *card, u64 mask)
{ {
int status; int status;
...@@ -79,51 +79,40 @@ static int gelic_net_set_irq_mask(struct gelic_net_card *card, u64 mask) ...@@ -79,51 +79,40 @@ static int gelic_net_set_irq_mask(struct gelic_net_card *card, u64 mask)
"lv1_net_set_interrupt_mask failed %d\n", status); "lv1_net_set_interrupt_mask failed %d\n", status);
return status; return status;
} }
static inline void gelic_net_rx_irq_on(struct gelic_net_card *card) static inline void gelic_card_rx_irq_on(struct gelic_card *card)
{ {
gelic_net_set_irq_mask(card, card->ghiintmask | GELIC_NET_RXINT); gelic_card_set_irq_mask(card, card->ghiintmask | GELIC_CARD_RXINT);
} }
static inline void gelic_net_rx_irq_off(struct gelic_net_card *card) static inline void gelic_card_rx_irq_off(struct gelic_card *card)
{ {
gelic_net_set_irq_mask(card, card->ghiintmask & ~GELIC_NET_RXINT); gelic_card_set_irq_mask(card, card->ghiintmask & ~GELIC_CARD_RXINT);
} }
/** /**
* gelic_net_get_descr_status -- returns the status of a descriptor * gelic_descr_get_status -- returns the status of a descriptor
* @descr: descriptor to look at * @descr: descriptor to look at
* *
* returns the status as in the dmac_cmd_status field of the descriptor * returns the status as in the dmac_cmd_status field of the descriptor
*/ */
static enum gelic_net_descr_status static enum gelic_descr_dma_status
gelic_net_get_descr_status(struct gelic_net_descr *descr) gelic_descr_get_status(struct gelic_descr *descr)
{ {
u32 cmd_status; return be32_to_cpu(descr->dmac_cmd_status) & GELIC_DESCR_DMA_STAT_MASK;
cmd_status = be32_to_cpu(descr->dmac_cmd_status);
cmd_status >>= GELIC_NET_DESCR_IND_PROC_SHIFT;
return cmd_status;
} }
/** /**
* gelic_net_set_descr_status -- sets the status of a descriptor * gelic_descr_set_status -- sets the status of a descriptor
* @descr: descriptor to change * @descr: descriptor to change
* @status: status to set in the descriptor * @status: status to set in the descriptor
* *
* changes the status to the specified value. Doesn't change other bits * changes the status to the specified value. Doesn't change other bits
* in the status * in the status
*/ */
static void gelic_net_set_descr_status(struct gelic_net_descr *descr, static void gelic_descr_set_status(struct gelic_descr *descr,
enum gelic_net_descr_status status) enum gelic_descr_dma_status status)
{ {
u32 cmd_status; descr->dmac_cmd_status = cpu_to_be32(status |
(be32_to_cpu(descr->dmac_cmd_status) &
/* read the status */ ~GELIC_DESCR_DMA_STAT_MASK));
cmd_status = be32_to_cpu(descr->dmac_cmd_status);
/* clean the upper 4 bits */
cmd_status &= GELIC_NET_DESCR_IND_PROC_MASKO;
/* add the status to it */
cmd_status |= ((u32)status) << GELIC_NET_DESCR_IND_PROC_SHIFT;
/* and write it back */
descr->dmac_cmd_status = cpu_to_be32(cmd_status);
/* /*
* dma_cmd_status field is used to indicate whether the descriptor * dma_cmd_status field is used to indicate whether the descriptor
* is valid or not. * is valid or not.
...@@ -134,24 +123,24 @@ static void gelic_net_set_descr_status(struct gelic_net_descr *descr, ...@@ -134,24 +123,24 @@ static void gelic_net_set_descr_status(struct gelic_net_descr *descr,
} }
/** /**
* gelic_net_free_chain - free descriptor chain * gelic_card_free_chain - free descriptor chain
* @card: card structure * @card: card structure
* @descr_in: address of desc * @descr_in: address of desc
*/ */
static void gelic_net_free_chain(struct gelic_net_card *card, static void gelic_card_free_chain(struct gelic_card *card,
struct gelic_net_descr *descr_in) struct gelic_descr *descr_in)
{ {
struct gelic_net_descr *descr; struct gelic_descr *descr;
for (descr = descr_in; descr && descr->bus_addr; descr = descr->next) { for (descr = descr_in; descr && descr->bus_addr; descr = descr->next) {
dma_unmap_single(ctodev(card), descr->bus_addr, dma_unmap_single(ctodev(card), descr->bus_addr,
GELIC_NET_DESCR_SIZE, DMA_BIDIRECTIONAL); GELIC_DESCR_SIZE, DMA_BIDIRECTIONAL);
descr->bus_addr = 0; descr->bus_addr = 0;
} }
} }
/** /**
* gelic_net_init_chain - links descriptor chain * gelic_card_init_chain - links descriptor chain
* @card: card structure * @card: card structure
* @chain: address of chain * @chain: address of chain
* @start_descr: address of descriptor array * @start_descr: address of descriptor array
...@@ -162,22 +151,22 @@ static void gelic_net_free_chain(struct gelic_net_card *card, ...@@ -162,22 +151,22 @@ static void gelic_net_free_chain(struct gelic_net_card *card,
* *
* returns 0 on success, <0 on failure * returns 0 on success, <0 on failure
*/ */
static int gelic_net_init_chain(struct gelic_net_card *card, static int gelic_card_init_chain(struct gelic_card *card,
struct gelic_net_descr_chain *chain, struct gelic_descr_chain *chain,
struct gelic_net_descr *start_descr, int no) struct gelic_descr *start_descr, int no)
{ {
int i; int i;
struct gelic_net_descr *descr; struct gelic_descr *descr;
descr = start_descr; descr = start_descr;
memset(descr, 0, sizeof(*descr) * no); memset(descr, 0, sizeof(*descr) * no);
/* set up the hardware pointers in each descriptor */ /* set up the hardware pointers in each descriptor */
for (i = 0; i < no; i++, descr++) { for (i = 0; i < no; i++, descr++) {
gelic_net_set_descr_status(descr, GELIC_NET_DESCR_NOT_IN_USE); gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
descr->bus_addr = descr->bus_addr =
dma_map_single(ctodev(card), descr, dma_map_single(ctodev(card), descr,
GELIC_NET_DESCR_SIZE, GELIC_DESCR_SIZE,
DMA_BIDIRECTIONAL); DMA_BIDIRECTIONAL);
if (!descr->bus_addr) if (!descr->bus_addr)
...@@ -208,13 +197,13 @@ static int gelic_net_init_chain(struct gelic_net_card *card, ...@@ -208,13 +197,13 @@ static int gelic_net_init_chain(struct gelic_net_card *card,
for (i--, descr--; 0 <= i; i--, descr--) for (i--, descr--; 0 <= i; i--, descr--)
if (descr->bus_addr) if (descr->bus_addr)
dma_unmap_single(ctodev(card), descr->bus_addr, dma_unmap_single(ctodev(card), descr->bus_addr,
GELIC_NET_DESCR_SIZE, GELIC_DESCR_SIZE,
DMA_BIDIRECTIONAL); DMA_BIDIRECTIONAL);
return -ENOMEM; return -ENOMEM;
} }
/** /**
* gelic_net_prepare_rx_descr - reinitializes a rx descriptor * gelic_descr_prepare_rx - reinitializes a rx descriptor
* @card: card structure * @card: card structure
* @descr: descriptor to re-init * @descr: descriptor to re-init
* *
...@@ -223,15 +212,15 @@ static int gelic_net_init_chain(struct gelic_net_card *card, ...@@ -223,15 +212,15 @@ static int gelic_net_init_chain(struct gelic_net_card *card,
* allocates a new rx skb, iommu-maps it and attaches it to the descriptor. * allocates a new rx skb, iommu-maps it and attaches it to the descriptor.
* Activate the descriptor state-wise * Activate the descriptor state-wise
*/ */
static int gelic_net_prepare_rx_descr(struct gelic_net_card *card, static int gelic_descr_prepare_rx(struct gelic_card *card,
struct gelic_net_descr *descr) struct gelic_descr *descr)
{ {
int offset; int offset;
unsigned int bufsize; unsigned int bufsize;
if (gelic_net_get_descr_status(descr) != GELIC_NET_DESCR_NOT_IN_USE) { if (gelic_descr_get_status(descr) != GELIC_DESCR_DMA_NOT_IN_USE)
dev_info(ctodev(card), "%s: ERROR status \n", __func__); dev_info(ctodev(card), "%s: ERROR status \n", __func__);
}
/* we need to round up the buffer size to a multiple of 128 */ /* we need to round up the buffer size to a multiple of 128 */
bufsize = ALIGN(GELIC_NET_MAX_MTU, GELIC_NET_RXBUF_ALIGN); bufsize = ALIGN(GELIC_NET_MAX_MTU, GELIC_NET_RXBUF_ALIGN);
...@@ -265,22 +254,22 @@ static int gelic_net_prepare_rx_descr(struct gelic_net_card *card, ...@@ -265,22 +254,22 @@ static int gelic_net_prepare_rx_descr(struct gelic_net_card *card,
descr->skb = NULL; descr->skb = NULL;
dev_info(ctodev(card), dev_info(ctodev(card),
"%s:Could not iommu-map rx buffer\n", __func__); "%s:Could not iommu-map rx buffer\n", __func__);
gelic_net_set_descr_status(descr, GELIC_NET_DESCR_NOT_IN_USE); gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
return -ENOMEM; return -ENOMEM;
} else { } else {
gelic_net_set_descr_status(descr, GELIC_NET_DESCR_CARDOWNED); gelic_descr_set_status(descr, GELIC_DESCR_DMA_CARDOWNED);
return 0; return 0;
} }
} }
/** /**
* gelic_net_release_rx_chain - free all skb of rx descr * gelic_card_release_rx_chain - free all skb of rx descr
* @card: card structure * @card: card structure
* *
*/ */
static void gelic_net_release_rx_chain(struct gelic_net_card *card) static void gelic_card_release_rx_chain(struct gelic_card *card)
{ {
struct gelic_net_descr *descr = card->rx_chain.head; struct gelic_descr *descr = card->rx_chain.head;
do { do {
if (descr->skb) { if (descr->skb) {
...@@ -291,29 +280,29 @@ static void gelic_net_release_rx_chain(struct gelic_net_card *card) ...@@ -291,29 +280,29 @@ static void gelic_net_release_rx_chain(struct gelic_net_card *card)
descr->buf_addr = 0; descr->buf_addr = 0;
dev_kfree_skb_any(descr->skb); dev_kfree_skb_any(descr->skb);
descr->skb = NULL; descr->skb = NULL;
gelic_net_set_descr_status(descr, gelic_descr_set_status(descr,
GELIC_NET_DESCR_NOT_IN_USE); GELIC_DESCR_DMA_NOT_IN_USE);
} }
descr = descr->next; descr = descr->next;
} while (descr != card->rx_chain.head); } while (descr != card->rx_chain.head);
} }
/** /**
* gelic_net_fill_rx_chain - fills descriptors/skbs in the rx chains * gelic_card_fill_rx_chain - fills descriptors/skbs in the rx chains
* @card: card structure * @card: card structure
* *
* fills all descriptors in the rx chain: allocates skbs * fills all descriptors in the rx chain: allocates skbs
* and iommu-maps them. * and iommu-maps them.
* returns 0 on success, <0 on failure * returns 0 on success, < 0 on failure
*/ */
static int gelic_net_fill_rx_chain(struct gelic_net_card *card) static int gelic_card_fill_rx_chain(struct gelic_card *card)
{ {
struct gelic_net_descr *descr = card->rx_chain.head; struct gelic_descr *descr = card->rx_chain.head;
int ret; int ret;
do { do {
if (!descr->skb) { if (!descr->skb) {
ret = gelic_net_prepare_rx_descr(card, descr); ret = gelic_descr_prepare_rx(card, descr);
if (ret) if (ret)
goto rewind; goto rewind;
} }
...@@ -322,41 +311,42 @@ static int gelic_net_fill_rx_chain(struct gelic_net_card *card) ...@@ -322,41 +311,42 @@ static int gelic_net_fill_rx_chain(struct gelic_net_card *card)
return 0; return 0;
rewind: rewind:
gelic_net_release_rx_chain(card); gelic_card_release_rx_chain(card);
return ret; return ret;
} }
/** /**
* gelic_net_alloc_rx_skbs - allocates rx skbs in rx descriptor chains * gelic_card_alloc_rx_skbs - allocates rx skbs in rx descriptor chains
* @card: card structure * @card: card structure
* *
* returns 0 on success, <0 on failure * returns 0 on success, < 0 on failure
*/ */
static int gelic_net_alloc_rx_skbs(struct gelic_net_card *card) static int gelic_card_alloc_rx_skbs(struct gelic_card *card)
{ {
struct gelic_net_descr_chain *chain; struct gelic_descr_chain *chain;
int ret; int ret;
chain = &card->rx_chain; chain = &card->rx_chain;
ret = gelic_net_fill_rx_chain(card); ret = gelic_card_fill_rx_chain(card);
chain->head = card->rx_top->prev; /* point to the last */ chain->head = card->rx_top->prev; /* point to the last */
return ret; return ret;
} }
/** /**
* gelic_net_release_tx_descr - processes a used tx descriptor * gelic_descr_release_tx - processes a used tx descriptor
* @card: card structure * @card: card structure
* @descr: descriptor to release * @descr: descriptor to release
* *
* releases a used tx descriptor (unmapping, freeing of skb) * releases a used tx descriptor (unmapping, freeing of skb)
*/ */
static void gelic_net_release_tx_descr(struct gelic_net_card *card, static void gelic_descr_release_tx(struct gelic_card *card,
struct gelic_net_descr *descr) struct gelic_descr *descr)
{ {
struct sk_buff *skb = descr->skb; struct sk_buff *skb = descr->skb;
#ifdef DEBUG
BUG_ON(!(be32_to_cpu(descr->data_status) & BUG_ON(!(be32_to_cpu(descr->data_status) &
(1 << GELIC_NET_TXDESC_TAIL))); (1 << GELIC_DESCR_TX_DMA_FRAME_TAIL)));
#endif
dma_unmap_single(ctodev(card), dma_unmap_single(ctodev(card),
be32_to_cpu(descr->buf_addr), skb->len, DMA_TO_DEVICE); be32_to_cpu(descr->buf_addr), skb->len, DMA_TO_DEVICE);
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
...@@ -371,30 +361,30 @@ static void gelic_net_release_tx_descr(struct gelic_net_card *card, ...@@ -371,30 +361,30 @@ static void gelic_net_release_tx_descr(struct gelic_net_card *card,
descr->skb = NULL; descr->skb = NULL;
/* set descr status */ /* set descr status */
gelic_net_set_descr_status(descr, GELIC_NET_DESCR_NOT_IN_USE); gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
} }
/** /**
* gelic_net_release_tx_chain - processes sent tx descriptors * gelic_card_release_tx_chain - processes sent tx descriptors
* @card: adapter structure * @card: adapter structure
* @stop: net_stop sequence * @stop: net_stop sequence
* *
* releases the tx descriptors that gelic has finished with * releases the tx descriptors that gelic has finished with
*/ */
static void gelic_net_release_tx_chain(struct gelic_net_card *card, int stop) static void gelic_card_release_tx_chain(struct gelic_card *card, int stop)
{ {
struct gelic_net_descr_chain *tx_chain; struct gelic_descr_chain *tx_chain;
enum gelic_net_descr_status status; enum gelic_descr_dma_status status;
int release = 0; int release = 0;
for (tx_chain = &card->tx_chain; for (tx_chain = &card->tx_chain;
tx_chain->head != tx_chain->tail && tx_chain->tail; tx_chain->head != tx_chain->tail && tx_chain->tail;
tx_chain->tail = tx_chain->tail->next) { tx_chain->tail = tx_chain->tail->next) {
status = gelic_net_get_descr_status(tx_chain->tail); status = gelic_descr_get_status(tx_chain->tail);
switch (status) { switch (status) {
case GELIC_NET_DESCR_RESPONSE_ERROR: case GELIC_DESCR_DMA_RESPONSE_ERROR:
case GELIC_NET_DESCR_PROTECTION_ERROR: case GELIC_DESCR_DMA_PROTECTION_ERROR:
case GELIC_NET_DESCR_FORCE_END: case GELIC_DESCR_DMA_FORCE_END:
if (printk_ratelimit()) if (printk_ratelimit())
dev_info(ctodev(card), dev_info(ctodev(card),
"%s: forcing end of tx descriptor " \ "%s: forcing end of tx descriptor " \
...@@ -403,7 +393,7 @@ static void gelic_net_release_tx_chain(struct gelic_net_card *card, int stop) ...@@ -403,7 +393,7 @@ static void gelic_net_release_tx_chain(struct gelic_net_card *card, int stop)
card->netdev->stats.tx_dropped++; card->netdev->stats.tx_dropped++;
break; break;
case GELIC_NET_DESCR_COMPLETE: case GELIC_DESCR_DMA_COMPLETE:
if (tx_chain->tail->skb) { if (tx_chain->tail->skb) {
card->netdev->stats.tx_packets++; card->netdev->stats.tx_packets++;
card->netdev->stats.tx_bytes += card->netdev->stats.tx_bytes +=
...@@ -411,14 +401,14 @@ static void gelic_net_release_tx_chain(struct gelic_net_card *card, int stop) ...@@ -411,14 +401,14 @@ static void gelic_net_release_tx_chain(struct gelic_net_card *card, int stop)
} }
break; break;
case GELIC_NET_DESCR_CARDOWNED: case GELIC_DESCR_DMA_CARDOWNED:
/* pending tx request */ /* pending tx request */
default: default:
/* any other value (== GELIC_NET_DESCR_NOT_IN_USE) */ /* any other value (== GELIC_DESCR_DMA_NOT_IN_USE) */
if (!stop) if (!stop)
goto out; goto out;
} }
gelic_net_release_tx_descr(card, tx_chain->tail); gelic_descr_release_tx(card, tx_chain->tail);
release ++; release ++;
} }
out: out:
...@@ -436,7 +426,7 @@ static void gelic_net_release_tx_chain(struct gelic_net_card *card, int stop) ...@@ -436,7 +426,7 @@ static void gelic_net_release_tx_chain(struct gelic_net_card *card, int stop)
*/ */
static void gelic_net_set_multi(struct net_device *netdev) static void gelic_net_set_multi(struct net_device *netdev)
{ {
struct gelic_net_card *card = netdev_priv(netdev); struct gelic_card *card = netdev_priv(netdev);
struct dev_mc_list *mc; struct dev_mc_list *mc;
unsigned int i; unsigned int i;
uint8_t *p; uint8_t *p;
...@@ -489,13 +479,13 @@ static void gelic_net_set_multi(struct net_device *netdev) ...@@ -489,13 +479,13 @@ static void gelic_net_set_multi(struct net_device *netdev)
} }
/** /**
* gelic_net_enable_rxdmac - enables the receive DMA controller * gelic_card_enable_rxdmac - enables the receive DMA controller
* @card: card structure * @card: card structure
* *
* gelic_net_enable_rxdmac enables the DMA controller by setting RX_DMA_EN * gelic_card_enable_rxdmac enables the DMA controller by setting RX_DMA_EN
* in the GDADMACCNTR register * in the GDADMACCNTR register
*/ */
static inline void gelic_net_enable_rxdmac(struct gelic_net_card *card) static inline void gelic_card_enable_rxdmac(struct gelic_card *card)
{ {
int status; int status;
...@@ -507,13 +497,13 @@ static inline void gelic_net_enable_rxdmac(struct gelic_net_card *card) ...@@ -507,13 +497,13 @@ static inline void gelic_net_enable_rxdmac(struct gelic_net_card *card)
} }
/** /**
* gelic_net_disable_rxdmac - disables the receive DMA controller * gelic_card_disable_rxdmac - disables the receive DMA controller
* @card: card structure * @card: card structure
* *
* gelic_net_disable_rxdmac terminates processing on the DMA controller by * gelic_card_disable_rxdmac terminates processing on the DMA controller by
* turing off DMA and issueing a force end * turing off DMA and issueing a force end
*/ */
static inline void gelic_net_disable_rxdmac(struct gelic_net_card *card) static inline void gelic_card_disable_rxdmac(struct gelic_card *card)
{ {
int status; int status;
...@@ -525,13 +515,13 @@ static inline void gelic_net_disable_rxdmac(struct gelic_net_card *card) ...@@ -525,13 +515,13 @@ static inline void gelic_net_disable_rxdmac(struct gelic_net_card *card)
} }
/** /**
* gelic_net_disable_txdmac - disables the transmit DMA controller * gelic_card_disable_txdmac - disables the transmit DMA controller
* @card: card structure * @card: card structure
* *
* gelic_net_disable_txdmac terminates processing on the DMA controller by * gelic_card_disable_txdmac terminates processing on the DMA controller by
* turing off DMA and issueing a force end * turing off DMA and issueing a force end
*/ */
static inline void gelic_net_disable_txdmac(struct gelic_net_card *card) static inline void gelic_card_disable_txdmac(struct gelic_card *card)
{ {
int status; int status;
...@@ -550,16 +540,16 @@ static inline void gelic_net_disable_txdmac(struct gelic_net_card *card) ...@@ -550,16 +540,16 @@ static inline void gelic_net_disable_txdmac(struct gelic_net_card *card)
*/ */
static int gelic_net_stop(struct net_device *netdev) static int gelic_net_stop(struct net_device *netdev)
{ {
struct gelic_net_card *card = netdev_priv(netdev); struct gelic_card *card = netdev_priv(netdev);
napi_disable(&card->napi); napi_disable(&card->napi);
netif_stop_queue(netdev); netif_stop_queue(netdev);
/* turn off DMA, force end */ /* turn off DMA, force end */
gelic_net_disable_rxdmac(card); gelic_card_disable_rxdmac(card);
gelic_net_disable_txdmac(card); gelic_card_disable_txdmac(card);
gelic_net_set_irq_mask(card, 0); gelic_card_set_irq_mask(card, 0);
/* disconnect event port */ /* disconnect event port */
free_irq(card->netdev->irq, card->netdev); free_irq(card->netdev->irq, card->netdev);
...@@ -569,30 +559,30 @@ static int gelic_net_stop(struct net_device *netdev) ...@@ -569,30 +559,30 @@ static int gelic_net_stop(struct net_device *netdev)
netif_carrier_off(netdev); netif_carrier_off(netdev);
/* release chains */ /* release chains */
gelic_net_release_tx_chain(card, 1); gelic_card_release_tx_chain(card, 1);
gelic_net_release_rx_chain(card); gelic_card_release_rx_chain(card);
gelic_net_free_chain(card, card->tx_top); gelic_card_free_chain(card, card->tx_top);
gelic_net_free_chain(card, card->rx_top); gelic_card_free_chain(card, card->rx_top);
return 0; return 0;
} }
/** /**
* gelic_net_get_next_tx_descr - returns the next available tx descriptor * gelic_card_get_next_tx_descr - returns the next available tx descriptor
* @card: device structure to get descriptor from * @card: device structure to get descriptor from
* *
* returns the address of the next descriptor, or NULL if not available. * returns the address of the next descriptor, or NULL if not available.
*/ */
static struct gelic_net_descr * static struct gelic_descr *
gelic_net_get_next_tx_descr(struct gelic_net_card *card) gelic_card_get_next_tx_descr(struct gelic_card *card)
{ {
if (!card->tx_chain.head) if (!card->tx_chain.head)
return NULL; return NULL;
/* see if the next descriptor is free */ /* see if the next descriptor is free */
if (card->tx_chain.tail != card->tx_chain.head->next && if (card->tx_chain.tail != card->tx_chain.head->next &&
gelic_net_get_descr_status(card->tx_chain.head) == gelic_descr_get_status(card->tx_chain.head) ==
GELIC_NET_DESCR_NOT_IN_USE) GELIC_DESCR_DMA_NOT_IN_USE)
return card->tx_chain.head; return card->tx_chain.head;
else else
return NULL; return NULL;
...@@ -600,7 +590,7 @@ gelic_net_get_next_tx_descr(struct gelic_net_card *card) ...@@ -600,7 +590,7 @@ gelic_net_get_next_tx_descr(struct gelic_net_card *card)
} }
/** /**
* gelic_net_set_txdescr_cmdstat - sets the tx descriptor command field * gelic_descr_set_tx_cmdstat - sets the tx descriptor command field
* @descr: descriptor structure to fill out * @descr: descriptor structure to fill out
* @skb: packet to consider * @skb: packet to consider
* *
...@@ -608,33 +598,33 @@ gelic_net_get_next_tx_descr(struct gelic_net_card *card) ...@@ -608,33 +598,33 @@ gelic_net_get_next_tx_descr(struct gelic_net_card *card)
* depending on hardware checksum settings. This function assumes a wmb() * depending on hardware checksum settings. This function assumes a wmb()
* has executed before. * has executed before.
*/ */
static void gelic_net_set_txdescr_cmdstat(struct gelic_net_descr *descr, static void gelic_descr_set_tx_cmdstat(struct gelic_descr *descr,
struct sk_buff *skb) struct sk_buff *skb)
{ {
if (skb->ip_summed != CHECKSUM_PARTIAL) if (skb->ip_summed != CHECKSUM_PARTIAL)
descr->dmac_cmd_status = descr->dmac_cmd_status =
cpu_to_be32(GELIC_NET_DMAC_CMDSTAT_NOCS | cpu_to_be32(GELIC_DESCR_DMA_CMD_NO_CHKSUM |
GELIC_NET_DMAC_CMDSTAT_END_FRAME); GELIC_DESCR_TX_DMA_FRAME_TAIL);
else { else {
/* is packet ip? /* is packet ip?
* if yes: tcp? udp? */ * if yes: tcp? udp? */
if (skb->protocol == htons(ETH_P_IP)) { if (skb->protocol == htons(ETH_P_IP)) {
if (ip_hdr(skb)->protocol == IPPROTO_TCP) if (ip_hdr(skb)->protocol == IPPROTO_TCP)
descr->dmac_cmd_status = descr->dmac_cmd_status =
cpu_to_be32(GELIC_NET_DMAC_CMDSTAT_TCPCS | cpu_to_be32(GELIC_DESCR_DMA_CMD_TCP_CHKSUM |
GELIC_NET_DMAC_CMDSTAT_END_FRAME); GELIC_DESCR_TX_DMA_FRAME_TAIL);
else if (ip_hdr(skb)->protocol == IPPROTO_UDP) else if (ip_hdr(skb)->protocol == IPPROTO_UDP)
descr->dmac_cmd_status = descr->dmac_cmd_status =
cpu_to_be32(GELIC_NET_DMAC_CMDSTAT_UDPCS | cpu_to_be32(GELIC_DESCR_DMA_CMD_UDP_CHKSUM |
GELIC_NET_DMAC_CMDSTAT_END_FRAME); GELIC_DESCR_TX_DMA_FRAME_TAIL);
else /* else /*
* the stack should checksum non-tcp and non-udp * the stack should checksum non-tcp and non-udp
* packets on his own: NETIF_F_IP_CSUM * packets on his own: NETIF_F_IP_CSUM
*/ */
descr->dmac_cmd_status = descr->dmac_cmd_status =
cpu_to_be32(GELIC_NET_DMAC_CMDSTAT_NOCS | cpu_to_be32(GELIC_DESCR_DMA_CMD_NO_CHKSUM |
GELIC_NET_DMAC_CMDSTAT_END_FRAME); GELIC_DESCR_TX_DMA_FRAME_TAIL);
} }
} }
} }
...@@ -665,7 +655,7 @@ static inline struct sk_buff *gelic_put_vlan_tag(struct sk_buff *skb, ...@@ -665,7 +655,7 @@ static inline struct sk_buff *gelic_put_vlan_tag(struct sk_buff *skb,
} }
/** /**
* gelic_net_prepare_tx_descr_v - get dma address of skb_data * gelic_descr_prepare_tx - get dma address of skb_data
* @card: card structure * @card: card structure
* @descr: descriptor structure * @descr: descriptor structure
* @skb: packet to use * @skb: packet to use
...@@ -673,9 +663,9 @@ static inline struct sk_buff *gelic_put_vlan_tag(struct sk_buff *skb, ...@@ -673,9 +663,9 @@ static inline struct sk_buff *gelic_put_vlan_tag(struct sk_buff *skb,
* returns 0 on success, <0 on failure. * returns 0 on success, <0 on failure.
* *
*/ */
static int gelic_net_prepare_tx_descr_v(struct gelic_net_card *card, static int gelic_descr_prepare_tx(struct gelic_card *card,
struct gelic_net_descr *descr, struct gelic_descr *descr,
struct sk_buff *skb) struct sk_buff *skb)
{ {
dma_addr_t buf; dma_addr_t buf;
...@@ -702,7 +692,7 @@ static int gelic_net_prepare_tx_descr_v(struct gelic_net_card *card, ...@@ -702,7 +692,7 @@ static int gelic_net_prepare_tx_descr_v(struct gelic_net_card *card,
descr->skb = skb; descr->skb = skb;
descr->data_status = 0; descr->data_status = 0;
descr->next_descr_addr = 0; /* terminate hw descr */ descr->next_descr_addr = 0; /* terminate hw descr */
gelic_net_set_txdescr_cmdstat(descr, skb); gelic_descr_set_tx_cmdstat(descr, skb);
/* bump free descriptor pointer */ /* bump free descriptor pointer */
card->tx_chain.head = descr->next; card->tx_chain.head = descr->next;
...@@ -710,20 +700,20 @@ static int gelic_net_prepare_tx_descr_v(struct gelic_net_card *card, ...@@ -710,20 +700,20 @@ static int gelic_net_prepare_tx_descr_v(struct gelic_net_card *card,
} }
/** /**
* gelic_net_kick_txdma - enables TX DMA processing * gelic_card_kick_txdma - enables TX DMA processing
* @card: card structure * @card: card structure
* @descr: descriptor address to enable TX processing at * @descr: descriptor address to enable TX processing at
* *
*/ */
static int gelic_net_kick_txdma(struct gelic_net_card *card, static int gelic_card_kick_txdma(struct gelic_card *card,
struct gelic_net_descr *descr) struct gelic_descr *descr)
{ {
int status = 0; int status = 0;
if (card->tx_dma_progress) if (card->tx_dma_progress)
return 0; return 0;
if (gelic_net_get_descr_status(descr) == GELIC_NET_DESCR_CARDOWNED) { if (gelic_descr_get_status(descr) == GELIC_DESCR_DMA_CARDOWNED) {
card->tx_dma_progress = 1; card->tx_dma_progress = 1;
status = lv1_net_start_tx_dma(bus_id(card), dev_id(card), status = lv1_net_start_tx_dma(bus_id(card), dev_id(card),
descr->bus_addr, 0); descr->bus_addr, 0);
...@@ -743,16 +733,16 @@ static int gelic_net_kick_txdma(struct gelic_net_card *card, ...@@ -743,16 +733,16 @@ static int gelic_net_kick_txdma(struct gelic_net_card *card,
*/ */
static int gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev) static int gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev)
{ {
struct gelic_net_card *card = netdev_priv(netdev); struct gelic_card *card = netdev_priv(netdev);
struct gelic_net_descr *descr; struct gelic_descr *descr;
int result; int result;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&card->tx_dma_lock, flags); spin_lock_irqsave(&card->tx_dma_lock, flags);
gelic_net_release_tx_chain(card, 0); gelic_card_release_tx_chain(card, 0);
descr = gelic_net_get_next_tx_descr(card); descr = gelic_card_get_next_tx_descr(card);
if (!descr) { if (!descr) {
/* /*
* no more descriptors free * no more descriptors free
...@@ -762,7 +752,7 @@ static int gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev) ...@@ -762,7 +752,7 @@ static int gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev)
return NETDEV_TX_BUSY; return NETDEV_TX_BUSY;
} }
result = gelic_net_prepare_tx_descr_v(card, descr, skb); result = gelic_descr_prepare_tx(card, descr, skb);
if (result) { if (result) {
/* /*
* DMA map failed. As chanses are that failure * DMA map failed. As chanses are that failure
...@@ -783,14 +773,14 @@ static int gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev) ...@@ -783,14 +773,14 @@ static int gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev)
* ensure that the hardware sees it * ensure that the hardware sees it
*/ */
wmb(); wmb();
if (gelic_net_kick_txdma(card, descr)) { if (gelic_card_kick_txdma(card, descr)) {
/* /*
* kick failed. * kick failed.
* release descriptors which were just prepared * release descriptors which were just prepared
*/ */
card->netdev->stats.tx_dropped++; card->netdev->stats.tx_dropped++;
gelic_net_release_tx_descr(card, descr); gelic_descr_release_tx(card, descr);
gelic_net_release_tx_descr(card, descr->next); gelic_descr_release_tx(card, descr->next);
card->tx_chain.tail = descr->next->next; card->tx_chain.tail = descr->next->next;
dev_info(ctodev(card), "%s: kick failure\n", __func__); dev_info(ctodev(card), "%s: kick failure\n", __func__);
} else { } else {
...@@ -810,8 +800,8 @@ static int gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev) ...@@ -810,8 +800,8 @@ static int gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev)
* iommu-unmaps the skb, fills out skb structure and passes the data to the * iommu-unmaps the skb, fills out skb structure and passes the data to the
* stack. The descriptor state is not changed. * stack. The descriptor state is not changed.
*/ */
static void gelic_net_pass_skb_up(struct gelic_net_descr *descr, static void gelic_net_pass_skb_up(struct gelic_descr *descr,
struct gelic_net_card *card) struct gelic_card *card)
{ {
struct sk_buff *skb; struct sk_buff *skb;
struct net_device *netdev; struct net_device *netdev;
...@@ -845,8 +835,8 @@ static void gelic_net_pass_skb_up(struct gelic_net_descr *descr, ...@@ -845,8 +835,8 @@ static void gelic_net_pass_skb_up(struct gelic_net_descr *descr,
/* checksum offload */ /* checksum offload */
if (card->rx_csum) { if (card->rx_csum) {
if ((data_status & GELIC_NET_DATA_STATUS_CHK_MASK) && if ((data_status & GELIC_DESCR_DATA_STATUS_CHK_MASK) &&
(!(data_error & GELIC_NET_DATA_ERROR_CHK_MASK))) (!(data_error & GELIC_DESCR_DATA_ERROR_CHK_MASK)))
skb->ip_summed = CHECKSUM_UNNECESSARY; skb->ip_summed = CHECKSUM_UNNECESSARY;
else else
skb->ip_summed = CHECKSUM_NONE; skb->ip_summed = CHECKSUM_NONE;
...@@ -862,7 +852,7 @@ static void gelic_net_pass_skb_up(struct gelic_net_descr *descr, ...@@ -862,7 +852,7 @@ static void gelic_net_pass_skb_up(struct gelic_net_descr *descr,
} }
/** /**
* gelic_net_decode_one_descr - processes an rx descriptor * gelic_card_decode_one_descr - processes an rx descriptor
* @card: card structure * @card: card structure
* *
* returns 1 if a packet has been sent to the stack, otherwise 0 * returns 1 if a packet has been sent to the stack, otherwise 0
...@@ -870,37 +860,37 @@ static void gelic_net_pass_skb_up(struct gelic_net_descr *descr, ...@@ -870,37 +860,37 @@ static void gelic_net_pass_skb_up(struct gelic_net_descr *descr,
* processes an rx descriptor by iommu-unmapping the data buffer and passing * processes an rx descriptor by iommu-unmapping the data buffer and passing
* the packet up to the stack * the packet up to the stack
*/ */
static int gelic_net_decode_one_descr(struct gelic_net_card *card) static int gelic_card_decode_one_descr(struct gelic_card *card)
{ {
enum gelic_net_descr_status status; enum gelic_descr_dma_status status;
struct gelic_net_descr_chain *chain = &card->rx_chain; struct gelic_descr_chain *chain = &card->rx_chain;
struct gelic_net_descr *descr = chain->tail; struct gelic_descr *descr = chain->tail;
int dmac_chain_ended; int dmac_chain_ended;
status = gelic_net_get_descr_status(descr); status = gelic_descr_get_status(descr);
/* is this descriptor terminated with next_descr == NULL? */ /* is this descriptor terminated with next_descr == NULL? */
dmac_chain_ended = dmac_chain_ended =
be32_to_cpu(descr->dmac_cmd_status) & be32_to_cpu(descr->dmac_cmd_status) &
GELIC_NET_DMAC_CMDSTAT_RXDCEIS; GELIC_DESCR_RX_DMA_CHAIN_END;
if (status == GELIC_NET_DESCR_CARDOWNED) if (status == GELIC_DESCR_DMA_CARDOWNED)
return 0; return 0;
if (status == GELIC_NET_DESCR_NOT_IN_USE) { if (status == GELIC_DESCR_DMA_NOT_IN_USE) {
dev_dbg(ctodev(card), "dormant descr? %p\n", descr); dev_dbg(ctodev(card), "dormant descr? %p\n", descr);
return 0; return 0;
} }
if ((status == GELIC_NET_DESCR_RESPONSE_ERROR) || if ((status == GELIC_DESCR_DMA_RESPONSE_ERROR) ||
(status == GELIC_NET_DESCR_PROTECTION_ERROR) || (status == GELIC_DESCR_DMA_PROTECTION_ERROR) ||
(status == GELIC_NET_DESCR_FORCE_END)) { (status == GELIC_DESCR_DMA_FORCE_END)) {
dev_info(ctodev(card), "dropping RX descriptor with state %x\n", dev_info(ctodev(card), "dropping RX descriptor with state %x\n",
status); status);
card->netdev->stats.rx_dropped++; card->netdev->stats.rx_dropped++;
goto refill; goto refill;
} }
if (status == GELIC_NET_DESCR_BUFFER_FULL) { if (status == GELIC_DESCR_DMA_BUFFER_FULL) {
/* /*
* Buffer full would occur if and only if * Buffer full would occur if and only if
* the frame length was longer than the size of this * the frame length was longer than the size of this
...@@ -917,7 +907,7 @@ static int gelic_net_decode_one_descr(struct gelic_net_card *card) ...@@ -917,7 +907,7 @@ static int gelic_net_decode_one_descr(struct gelic_net_card *card)
* descriptoers any other than FRAME_END here should * descriptoers any other than FRAME_END here should
* be treated as error. * be treated as error.
*/ */
if (status != GELIC_NET_DESCR_FRAME_END) { if (status != GELIC_DESCR_DMA_FRAME_END) {
dev_dbg(ctodev(card), "RX descriptor with state %x\n", dev_dbg(ctodev(card), "RX descriptor with state %x\n",
status); status);
goto refill; goto refill;
...@@ -934,13 +924,13 @@ static int gelic_net_decode_one_descr(struct gelic_net_card *card) ...@@ -934,13 +924,13 @@ static int gelic_net_decode_one_descr(struct gelic_net_card *card)
descr->next_descr_addr = 0; descr->next_descr_addr = 0;
/* change the descriptor state: */ /* change the descriptor state: */
gelic_net_set_descr_status(descr, GELIC_NET_DESCR_NOT_IN_USE); gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
/* /*
* this call can fail, but for now, just leave this * this call can fail, but for now, just leave this
* decriptor without skb * decriptor without skb
*/ */
gelic_net_prepare_rx_descr(card, descr); gelic_descr_prepare_rx(card, descr);
chain->head = descr; chain->head = descr;
chain->tail = descr->next; chain->tail = descr->next;
...@@ -973,12 +963,12 @@ static int gelic_net_decode_one_descr(struct gelic_net_card *card) ...@@ -973,12 +963,12 @@ static int gelic_net_decode_one_descr(struct gelic_net_card *card)
*/ */
static int gelic_net_poll(struct napi_struct *napi, int budget) static int gelic_net_poll(struct napi_struct *napi, int budget)
{ {
struct gelic_net_card *card = container_of(napi, struct gelic_net_card, napi); struct gelic_card *card = container_of(napi, struct gelic_card, napi);
struct net_device *netdev = card->netdev; struct net_device *netdev = card->netdev;
int packets_done = 0; int packets_done = 0;
while (packets_done < budget) { while (packets_done < budget) {
if (!gelic_net_decode_one_descr(card)) if (!gelic_card_decode_one_descr(card))
break; break;
packets_done++; packets_done++;
...@@ -986,7 +976,7 @@ static int gelic_net_poll(struct napi_struct *napi, int budget) ...@@ -986,7 +976,7 @@ static int gelic_net_poll(struct napi_struct *napi, int budget)
if (packets_done < budget) { if (packets_done < budget) {
netif_rx_complete(netdev, napi); netif_rx_complete(netdev, napi);
gelic_net_rx_irq_on(card); gelic_card_rx_irq_on(card);
} }
return packets_done; return packets_done;
} }
...@@ -1010,13 +1000,13 @@ static int gelic_net_change_mtu(struct net_device *netdev, int new_mtu) ...@@ -1010,13 +1000,13 @@ static int gelic_net_change_mtu(struct net_device *netdev, int new_mtu)
} }
/** /**
* gelic_net_interrupt - event handler for gelic_net * gelic_card_interrupt - event handler for gelic_net
*/ */
static irqreturn_t gelic_net_interrupt(int irq, void *ptr) static irqreturn_t gelic_card_interrupt(int irq, void *ptr)
{ {
unsigned long flags; unsigned long flags;
struct net_device *netdev = ptr; struct net_device *netdev = ptr;
struct gelic_net_card *card = netdev_priv(netdev); struct gelic_card *card = netdev_priv(netdev);
u64 status; u64 status;
status = card->irq_status; status = card->irq_status;
...@@ -1026,20 +1016,20 @@ static irqreturn_t gelic_net_interrupt(int irq, void *ptr) ...@@ -1026,20 +1016,20 @@ static irqreturn_t gelic_net_interrupt(int irq, void *ptr)
if (card->rx_dma_restart_required) { if (card->rx_dma_restart_required) {
card->rx_dma_restart_required = 0; card->rx_dma_restart_required = 0;
gelic_net_enable_rxdmac(card); gelic_card_enable_rxdmac(card);
} }
if (status & GELIC_NET_RXINT) { if (status & GELIC_CARD_RXINT) {
gelic_net_rx_irq_off(card); gelic_card_rx_irq_off(card);
netif_rx_schedule(netdev, &card->napi); netif_rx_schedule(netdev, &card->napi);
} }
if (status & GELIC_NET_TXINT) { if (status & GELIC_CARD_TXINT) {
spin_lock_irqsave(&card->tx_dma_lock, flags); spin_lock_irqsave(&card->tx_dma_lock, flags);
card->tx_dma_progress = 0; card->tx_dma_progress = 0;
gelic_net_release_tx_chain(card, 0); gelic_card_release_tx_chain(card, 0);
/* kick outstanding tx descriptor if any */ /* kick outstanding tx descriptor if any */
gelic_net_kick_txdma(card, card->tx_chain.tail); gelic_card_kick_txdma(card, card->tx_chain.tail);
spin_unlock_irqrestore(&card->tx_dma_lock, flags); spin_unlock_irqrestore(&card->tx_dma_lock, flags);
} }
return IRQ_HANDLED; return IRQ_HANDLED;
...@@ -1054,19 +1044,19 @@ static irqreturn_t gelic_net_interrupt(int irq, void *ptr) ...@@ -1054,19 +1044,19 @@ static irqreturn_t gelic_net_interrupt(int irq, void *ptr)
*/ */
static void gelic_net_poll_controller(struct net_device *netdev) static void gelic_net_poll_controller(struct net_device *netdev)
{ {
struct gelic_net_card *card = netdev_priv(netdev); struct gelic_card *card = netdev_priv(netdev);
gelic_net_set_irq_mask(card, 0); gelic_card_set_irq_mask(card, 0);
gelic_net_interrupt(netdev->irq, netdev); gelic_card_interrupt(netdev->irq, netdev);
gelic_net_set_irq_mask(card, card->ghiintmask); gelic_card_set_irq_mask(card, card->ghiintmask);
} }
#endif /* CONFIG_NET_POLL_CONTROLLER */ #endif /* CONFIG_NET_POLL_CONTROLLER */
/** /**
* gelic_net_open_device - open device and map dma region * gelic_card_open - open device and map dma region
* @card: card structure * @card: card structure
*/ */
static int gelic_net_open_device(struct gelic_net_card *card) static int gelic_card_open(struct gelic_card *card)
{ {
int result; int result;
...@@ -1075,13 +1065,13 @@ static int gelic_net_open_device(struct gelic_net_card *card) ...@@ -1075,13 +1065,13 @@ static int gelic_net_open_device(struct gelic_net_card *card)
if (result) { if (result) {
dev_info(ctodev(card), dev_info(ctodev(card),
"%s:%d: gelic_net_open_device failed (%d)\n", "%s:%d: recieve_port_setup failed (%d)\n",
__func__, __LINE__, result); __func__, __LINE__, result);
result = -EPERM; result = -EPERM;
goto fail_alloc_irq; goto fail_alloc_irq;
} }
result = request_irq(card->netdev->irq, gelic_net_interrupt, result = request_irq(card->netdev->irq, gelic_card_interrupt,
IRQF_DISABLED, card->netdev->name, card->netdev); IRQF_DISABLED, card->netdev->name, card->netdev);
if (result) { if (result) {
...@@ -1111,37 +1101,37 @@ static int gelic_net_open_device(struct gelic_net_card *card) ...@@ -1111,37 +1101,37 @@ static int gelic_net_open_device(struct gelic_net_card *card)
*/ */
static int gelic_net_open(struct net_device *netdev) static int gelic_net_open(struct net_device *netdev)
{ {
struct gelic_net_card *card = netdev_priv(netdev); struct gelic_card *card = netdev_priv(netdev);
dev_dbg(ctodev(card), " -> %s:%d\n", __func__, __LINE__); dev_dbg(ctodev(card), " -> %s:%d\n", __func__, __LINE__);
gelic_net_open_device(card); gelic_card_open(card);
if (gelic_net_init_chain(card, &card->tx_chain, if (gelic_card_init_chain(card, &card->tx_chain,
card->descr, GELIC_NET_TX_DESCRIPTORS)) card->descr, GELIC_NET_TX_DESCRIPTORS))
goto alloc_tx_failed; goto alloc_tx_failed;
if (gelic_net_init_chain(card, &card->rx_chain, if (gelic_card_init_chain(card, &card->rx_chain,
card->descr + GELIC_NET_TX_DESCRIPTORS, card->descr + GELIC_NET_TX_DESCRIPTORS,
GELIC_NET_RX_DESCRIPTORS)) GELIC_NET_RX_DESCRIPTORS))
goto alloc_rx_failed; goto alloc_rx_failed;
/* head of chain */ /* head of chain */
card->tx_top = card->tx_chain.head; card->tx_top = card->tx_chain.head;
card->rx_top = card->rx_chain.head; card->rx_top = card->rx_chain.head;
dev_dbg(ctodev(card), "descr rx %p, tx %p, size %#lx, num %#x\n", dev_dbg(ctodev(card), "descr rx %p, tx %p, size %#lx, num %#x\n",
card->rx_top, card->tx_top, sizeof(struct gelic_net_descr), card->rx_top, card->tx_top, sizeof(struct gelic_descr),
GELIC_NET_RX_DESCRIPTORS); GELIC_NET_RX_DESCRIPTORS);
/* allocate rx skbs */ /* allocate rx skbs */
if (gelic_net_alloc_rx_skbs(card)) if (gelic_card_alloc_rx_skbs(card))
goto alloc_skbs_failed; goto alloc_skbs_failed;
napi_enable(&card->napi); napi_enable(&card->napi);
card->tx_dma_progress = 0; card->tx_dma_progress = 0;
card->ghiintmask = GELIC_NET_RXINT | GELIC_NET_TXINT; card->ghiintmask = GELIC_CARD_RXINT | GELIC_CARD_TXINT;
gelic_net_set_irq_mask(card, card->ghiintmask); gelic_card_set_irq_mask(card, card->ghiintmask);
gelic_net_enable_rxdmac(card); gelic_card_enable_rxdmac(card);
netif_start_queue(netdev); netif_start_queue(netdev);
netif_carrier_on(netdev); netif_carrier_on(netdev);
...@@ -1149,46 +1139,47 @@ static int gelic_net_open(struct net_device *netdev) ...@@ -1149,46 +1139,47 @@ static int gelic_net_open(struct net_device *netdev)
return 0; return 0;
alloc_skbs_failed: alloc_skbs_failed:
gelic_net_free_chain(card, card->rx_top); gelic_card_free_chain(card, card->rx_top);
alloc_rx_failed: alloc_rx_failed:
gelic_net_free_chain(card, card->tx_top); gelic_card_free_chain(card, card->tx_top);
alloc_tx_failed: alloc_tx_failed:
return -ENOMEM; return -ENOMEM;
} }
static void gelic_net_get_drvinfo (struct net_device *netdev, static void gelic_net_get_drvinfo(struct net_device *netdev,
struct ethtool_drvinfo *info) struct ethtool_drvinfo *info)
{ {
strncpy(info->driver, DRV_NAME, sizeof(info->driver) - 1); strncpy(info->driver, DRV_NAME, sizeof(info->driver) - 1);
strncpy(info->version, DRV_VERSION, sizeof(info->version) - 1); strncpy(info->version, DRV_VERSION, sizeof(info->version) - 1);
} }
static int gelic_net_get_settings(struct net_device *netdev, static int gelic_ether_get_settings(struct net_device *netdev,
struct ethtool_cmd *cmd) struct ethtool_cmd *cmd)
{ {
struct gelic_net_card *card = netdev_priv(netdev); struct gelic_card *card = netdev_priv(netdev);
int status; int status;
u64 v1, v2; u64 v1, v2;
int speed, duplex; int speed, duplex;
speed = duplex = -1; speed = duplex = -1;
status = lv1_net_control(bus_id(card), dev_id(card), status = lv1_net_control(bus_id(card), dev_id(card),
GELIC_NET_GET_ETH_PORT_STATUS, GELIC_NET_PORT, 0, 0, GELIC_LV1_GET_ETH_PORT_STATUS,
&v1, &v2); GELIC_LV1_VLAN_TX_ETHERNET, 0, 0,
&v1, &v2);
if (status) { if (status) {
/* link down */ /* link down */
} else { } else {
if (v1 & GELIC_NET_FULL_DUPLEX) { if (v1 & GELIC_LV1_ETHER_FULL_DUPLEX) {
duplex = DUPLEX_FULL; duplex = DUPLEX_FULL;
} else { } else {
duplex = DUPLEX_HALF; duplex = DUPLEX_HALF;
} }
if (v1 & GELIC_NET_SPEED_10 ) { if (v1 & GELIC_LV1_ETHER_SPEED_10) {
speed = SPEED_10; speed = SPEED_10;
} else if (v1 & GELIC_NET_SPEED_100) { } else if (v1 & GELIC_LV1_ETHER_SPEED_100) {
speed = SPEED_100; speed = SPEED_100;
} else if (v1 & GELIC_NET_SPEED_1000) { } else if (v1 & GELIC_LV1_ETHER_SPEED_1000) {
speed = SPEED_1000; speed = SPEED_1000;
} }
} }
...@@ -1205,20 +1196,21 @@ static int gelic_net_get_settings(struct net_device *netdev, ...@@ -1205,20 +1196,21 @@ static int gelic_net_get_settings(struct net_device *netdev,
return 0; return 0;
} }
static u32 gelic_net_get_link(struct net_device *netdev) static u32 gelic_ether_get_link(struct net_device *netdev)
{ {
struct gelic_net_card *card = netdev_priv(netdev); struct gelic_card *card = netdev_priv(netdev);
int status; int status;
u64 v1, v2; u64 v1, v2;
int link; int link;
status = lv1_net_control(bus_id(card), dev_id(card), status = lv1_net_control(bus_id(card), dev_id(card),
GELIC_NET_GET_ETH_PORT_STATUS, GELIC_NET_PORT, 0, 0, GELIC_LV1_GET_ETH_PORT_STATUS,
&v1, &v2); GELIC_LV1_VLAN_TX_ETHERNET, 0, 0,
&v1, &v2);
if (status) if (status)
return 0; /* link down */ return 0; /* link down */
if (v1 & GELIC_NET_LINK_UP) if (v1 & GELIC_LV1_ETHER_LINK_UP)
link = 1; link = 1;
else else
link = 0; link = 0;
...@@ -1252,14 +1244,14 @@ static int gelic_net_set_tx_csum(struct net_device *netdev, u32 data) ...@@ -1252,14 +1244,14 @@ static int gelic_net_set_tx_csum(struct net_device *netdev, u32 data)
static u32 gelic_net_get_rx_csum(struct net_device *netdev) static u32 gelic_net_get_rx_csum(struct net_device *netdev)
{ {
struct gelic_net_card *card = netdev_priv(netdev); struct gelic_card *card = netdev_priv(netdev);
return card->rx_csum; return card->rx_csum;
} }
static int gelic_net_set_rx_csum(struct net_device *netdev, u32 data) static int gelic_net_set_rx_csum(struct net_device *netdev, u32 data)
{ {
struct gelic_net_card *card = netdev_priv(netdev); struct gelic_card *card = netdev_priv(netdev);
card->rx_csum = data; card->rx_csum = data;
return 0; return 0;
...@@ -1267,8 +1259,8 @@ static int gelic_net_set_rx_csum(struct net_device *netdev, u32 data) ...@@ -1267,8 +1259,8 @@ static int gelic_net_set_rx_csum(struct net_device *netdev, u32 data)
static struct ethtool_ops gelic_net_ethtool_ops = { static struct ethtool_ops gelic_net_ethtool_ops = {
.get_drvinfo = gelic_net_get_drvinfo, .get_drvinfo = gelic_net_get_drvinfo,
.get_settings = gelic_net_get_settings, .get_settings = gelic_ether_get_settings,
.get_link = gelic_net_get_link, .get_link = gelic_ether_get_link,
.nway_reset = gelic_net_nway_reset, .nway_reset = gelic_net_nway_reset,
.get_tx_csum = gelic_net_get_tx_csum, .get_tx_csum = gelic_net_get_tx_csum,
.set_tx_csum = gelic_net_set_tx_csum, .set_tx_csum = gelic_net_set_tx_csum,
...@@ -1285,8 +1277,8 @@ static struct ethtool_ops gelic_net_ethtool_ops = { ...@@ -1285,8 +1277,8 @@ static struct ethtool_ops gelic_net_ethtool_ops = {
*/ */
static void gelic_net_tx_timeout_task(struct work_struct *work) static void gelic_net_tx_timeout_task(struct work_struct *work)
{ {
struct gelic_net_card *card = struct gelic_card *card =
container_of(work, struct gelic_net_card, tx_timeout_task); container_of(work, struct gelic_card, tx_timeout_task);
struct net_device *netdev = card->netdev; struct net_device *netdev = card->netdev;
dev_info(ctodev(card), "%s:Timed out. Restarting... \n", __func__); dev_info(ctodev(card), "%s:Timed out. Restarting... \n", __func__);
...@@ -1312,7 +1304,7 @@ static void gelic_net_tx_timeout_task(struct work_struct *work) ...@@ -1312,7 +1304,7 @@ static void gelic_net_tx_timeout_task(struct work_struct *work)
*/ */
static void gelic_net_tx_timeout(struct net_device *netdev) static void gelic_net_tx_timeout(struct net_device *netdev)
{ {
struct gelic_net_card *card; struct gelic_card *card;
card = netdev_priv(netdev); card = netdev_priv(netdev);
atomic_inc(&card->tx_timeout_task_counter); atomic_inc(&card->tx_timeout_task_counter);
...@@ -1323,12 +1315,12 @@ static void gelic_net_tx_timeout(struct net_device *netdev) ...@@ -1323,12 +1315,12 @@ static void gelic_net_tx_timeout(struct net_device *netdev)
} }
/** /**
* gelic_net_setup_netdev_ops - initialization of net_device operations * gelic_ether_setup_netdev_ops - initialization of net_device operations
* @netdev: net_device structure * @netdev: net_device structure
* *
* fills out function pointers in the net_device structure * fills out function pointers in the net_device structure
*/ */
static void gelic_net_setup_netdev_ops(struct net_device *netdev) static void gelic_ether_setup_netdev_ops(struct net_device *netdev)
{ {
netdev->open = &gelic_net_open; netdev->open = &gelic_net_open;
netdev->stop = &gelic_net_stop; netdev->stop = &gelic_net_stop;
...@@ -1349,7 +1341,7 @@ static void gelic_net_setup_netdev_ops(struct net_device *netdev) ...@@ -1349,7 +1341,7 @@ static void gelic_net_setup_netdev_ops(struct net_device *netdev)
* *
* gelic_net_setup_netdev initializes the net_device structure * gelic_net_setup_netdev initializes the net_device structure
**/ **/
static int gelic_net_setup_netdev(struct gelic_net_card *card) static int gelic_net_setup_netdev(struct gelic_card *card)
{ {
struct net_device *netdev = card->netdev; struct net_device *netdev = card->netdev;
struct sockaddr addr; struct sockaddr addr;
...@@ -1363,7 +1355,7 @@ static int gelic_net_setup_netdev(struct gelic_net_card *card) ...@@ -1363,7 +1355,7 @@ static int gelic_net_setup_netdev(struct gelic_net_card *card)
card->rx_csum = GELIC_NET_RX_CSUM_DEFAULT; card->rx_csum = GELIC_NET_RX_CSUM_DEFAULT;
gelic_net_setup_netdev_ops(netdev); gelic_ether_setup_netdev_ops(netdev);
netif_napi_add(netdev, &card->napi, netif_napi_add(netdev, &card->napi,
gelic_net_poll, GELIC_NET_NAPI_WEIGHT); gelic_net_poll, GELIC_NET_NAPI_WEIGHT);
...@@ -1371,7 +1363,7 @@ static int gelic_net_setup_netdev(struct gelic_net_card *card) ...@@ -1371,7 +1363,7 @@ static int gelic_net_setup_netdev(struct gelic_net_card *card)
netdev->features = NETIF_F_IP_CSUM; netdev->features = NETIF_F_IP_CSUM;
status = lv1_net_control(bus_id(card), dev_id(card), status = lv1_net_control(bus_id(card), dev_id(card),
GELIC_NET_GET_MAC_ADDRESS, GELIC_LV1_GET_MAC_ADDRESS,
0, 0, 0, &v1, &v2); 0, 0, 0, &v1, &v2);
if (status || !is_valid_ether_addr((u8 *)&v1)) { if (status || !is_valid_ether_addr((u8 *)&v1)) {
dev_info(ctodev(card), dev_info(ctodev(card),
...@@ -1388,17 +1380,17 @@ static int gelic_net_setup_netdev(struct gelic_net_card *card) ...@@ -1388,17 +1380,17 @@ static int gelic_net_setup_netdev(struct gelic_net_card *card)
card->vlan_index = -1; /* no vlan */ card->vlan_index = -1; /* no vlan */
for (i = 0; i < GELIC_NET_VLAN_MAX; i++) { for (i = 0; i < GELIC_NET_VLAN_MAX; i++) {
status = lv1_net_control(bus_id(card), dev_id(card), status = lv1_net_control(bus_id(card), dev_id(card),
GELIC_NET_GET_VLAN_ID, GELIC_LV1_GET_VLAN_ID,
i + 1, /* index; one based */ i + 1, /* index; one based */
0, 0, &v1, &v2); 0, 0, &v1, &v2);
if (status == GELIC_NET_VLAN_NO_ENTRY) { if (status == LV1_NO_ENTRY) {
dev_dbg(ctodev(card), dev_dbg(ctodev(card),
"GELIC_VLAN_ID no entry:%d, VLAN disabled\n", "GELIC_VLAN_ID no entry:%d, VLAN disabled\n",
status); status);
card->vlan_id[i] = 0; card->vlan_id[i] = 0;
} else if (status) { } else if (status) {
dev_dbg(ctodev(card), dev_dbg(ctodev(card),
"%s:GELIC_NET_VLAN_ID faild, status=%d\n", "%s:get vlan id faild, status=%d\n",
__func__, status); __func__, status);
card->vlan_id[i] = 0; card->vlan_id[i] = 0;
} else { } else {
...@@ -1407,8 +1399,8 @@ static int gelic_net_setup_netdev(struct gelic_net_card *card) ...@@ -1407,8 +1399,8 @@ static int gelic_net_setup_netdev(struct gelic_net_card *card)
} }
} }
if (card->vlan_id[GELIC_NET_VLAN_WIRED - 1]) { if (card->vlan_id[GELIC_LV1_VLAN_TX_ETHERNET - 1]) {
card->vlan_index = GELIC_NET_VLAN_WIRED - 1; card->vlan_index = GELIC_LV1_VLAN_TX_ETHERNET - 1;
netdev->hard_header_len += VLAN_HLEN; netdev->hard_header_len += VLAN_HLEN;
} }
...@@ -1423,31 +1415,31 @@ static int gelic_net_setup_netdev(struct gelic_net_card *card) ...@@ -1423,31 +1415,31 @@ static int gelic_net_setup_netdev(struct gelic_net_card *card)
} }
/** /**
* gelic_net_alloc_card - allocates net_device and card structure * gelic_alloc_card_net - allocates net_device and card structure
* *
* returns the card structure or NULL in case of errors * returns the card structure or NULL in case of errors
* *
* the card and net_device structures are linked to each other * the card and net_device structures are linked to each other
*/ */
static struct gelic_net_card *gelic_net_alloc_card(void) static struct gelic_card *gelic_alloc_card_net(void)
{ {
struct net_device *netdev; struct net_device *netdev;
struct gelic_net_card *card; struct gelic_card *card;
size_t alloc_size; size_t alloc_size;
alloc_size = sizeof (*card) + alloc_size = sizeof(*card) +
sizeof (struct gelic_net_descr) * GELIC_NET_RX_DESCRIPTORS + sizeof(struct gelic_descr) * GELIC_NET_RX_DESCRIPTORS +
sizeof (struct gelic_net_descr) * GELIC_NET_TX_DESCRIPTORS; sizeof(struct gelic_descr) * GELIC_NET_TX_DESCRIPTORS;
/* /*
* we assume private data is allocated 32 bytes (or more) aligned * we assume private data is allocated 32 bytes (or more) aligned
* so that gelic_net_descr should be 32 bytes aligned. * so that gelic_descr should be 32 bytes aligned.
* Current alloc_etherdev() does do it because NETDEV_ALIGN * Current alloc_etherdev() does do it because NETDEV_ALIGN
* is 32. * is 32.
* check this assumption here. * check this assumption here.
*/ */
BUILD_BUG_ON(NETDEV_ALIGN < 32); BUILD_BUG_ON(NETDEV_ALIGN < 32);
BUILD_BUG_ON(offsetof(struct gelic_net_card, irq_status) % 8); BUILD_BUG_ON(offsetof(struct gelic_card, irq_status) % 8);
BUILD_BUG_ON(offsetof(struct gelic_net_card, descr) % 32); BUILD_BUG_ON(offsetof(struct gelic_card, descr) % 32);
netdev = alloc_etherdev(alloc_size); netdev = alloc_etherdev(alloc_size);
if (!netdev) if (!netdev)
...@@ -1465,9 +1457,9 @@ static struct gelic_net_card *gelic_net_alloc_card(void) ...@@ -1465,9 +1457,9 @@ static struct gelic_net_card *gelic_net_alloc_card(void)
/** /**
* ps3_gelic_driver_probe - add a device to the control of this driver * ps3_gelic_driver_probe - add a device to the control of this driver
*/ */
static int ps3_gelic_driver_probe (struct ps3_system_bus_device *dev) static int ps3_gelic_driver_probe(struct ps3_system_bus_device *dev)
{ {
struct gelic_net_card *card = gelic_net_alloc_card(); struct gelic_card *card = gelic_alloc_card_net();
int result; int result;
if (!card) { if (!card) {
...@@ -1537,9 +1529,9 @@ static int ps3_gelic_driver_probe (struct ps3_system_bus_device *dev) ...@@ -1537,9 +1529,9 @@ static int ps3_gelic_driver_probe (struct ps3_system_bus_device *dev)
* ps3_gelic_driver_remove - remove a device from the control of this driver * ps3_gelic_driver_remove - remove a device from the control of this driver
*/ */
static int ps3_gelic_driver_remove (struct ps3_system_bus_device *dev) static int ps3_gelic_driver_remove(struct ps3_system_bus_device *dev)
{ {
struct gelic_net_card *card = ps3_system_bus_get_driver_data(dev); struct gelic_card *card = ps3_system_bus_get_driver_data(dev);
wait_event(card->waitq, wait_event(card->waitq,
atomic_read(&card->tx_timeout_task_counter) == 0); atomic_read(&card->tx_timeout_task_counter) == 0);
...@@ -1580,8 +1572,8 @@ static void __exit ps3_gelic_driver_exit (void) ...@@ -1580,8 +1572,8 @@ static void __exit ps3_gelic_driver_exit (void)
ps3_system_bus_driver_unregister(&ps3_gelic_driver); ps3_system_bus_driver_unregister(&ps3_gelic_driver);
} }
module_init (ps3_gelic_driver_init); module_init(ps3_gelic_driver_init);
module_exit (ps3_gelic_driver_exit); module_exit(ps3_gelic_driver_exit);
MODULE_ALIAS(PS3_MODULE_ALIAS_GELIC); MODULE_ALIAS(PS3_MODULE_ALIAS_GELIC);
...@@ -43,131 +43,170 @@ ...@@ -43,131 +43,170 @@
#define GELIC_NET_VLAN_MAX 4 #define GELIC_NET_VLAN_MAX 4
#define GELIC_NET_MC_COUNT_MAX 32 /* multicast address list */ #define GELIC_NET_MC_COUNT_MAX 32 /* multicast address list */
enum gelic_net_int0_status { /* virtual interrupt status register bits */
GELIC_NET_GDTDCEINT = 24, /* INT1 */
GELIC_NET_GRFANMINT = 28, #define GELIC_CARD_TX_RAM_FULL_ERR 0x0000000000000001L
}; #define GELIC_CARD_RX_RAM_FULL_ERR 0x0000000000000002L
#define GELIC_CARD_TX_SHORT_FRAME_ERR 0x0000000000000004L
#define GELIC_CARD_TX_INVALID_DESCR_ERR 0x0000000000000008L
#define GELIC_CARD_RX_FIFO_FULL_ERR 0x0000000000002000L
#define GELIC_CARD_RX_DESCR_CHAIN_END 0x0000000000004000L
#define GELIC_CARD_RX_INVALID_DESCR_ERR 0x0000000000008000L
#define GELIC_CARD_TX_RESPONCE_ERR 0x0000000000010000L
#define GELIC_CARD_RX_RESPONCE_ERR 0x0000000000100000L
#define GELIC_CARD_TX_PROTECTION_ERR 0x0000000000400000L
#define GELIC_CARD_RX_PROTECTION_ERR 0x0000000004000000L
#define GELIC_CARD_TX_TCP_UDP_CHECKSUM_ERR 0x0000000008000000L
#define GELIC_CARD_PORT_STATUS_CHANGED 0x0000000020000000L
/* INT 0 */
#define GELIC_CARD_TX_FLAGGED_DESCR 0x0004000000000000L
#define GELIC_CARD_RX_FLAGGED_DESCR 0x0040000000000000L
#define GELIC_CARD_TX_TRANSFER_END 0x0080000000000000L
#define GELIC_CARD_TX_DESCR_CHAIN_END 0x0100000000000000L
#define GELIC_CARD_NUMBER_OF_RX_FRAME 0x1000000000000000L
#define GELIC_CARD_ONE_TIME_COUNT_TIMER 0x4000000000000000L
#define GELIC_CARD_FREE_RUN_COUNT_TIMER 0x8000000000000000L
/* initial interrupt mask */
#define GELIC_CARD_TXINT GELIC_CARD_TX_DESCR_CHAIN_END
#define GELIC_CARD_RXINT (GELIC_CARD_RX_DESCR_CHAIN_END | \
GELIC_CARD_NUMBER_OF_RX_FRAME)
/* GHIINT1STS bits */ /* RX descriptor data_status bits */
enum gelic_net_int1_status { enum gelic_descr_rx_status {
GELIC_NET_GDADCEINT = 14, GELIC_DESCR_RXDMADU = 0x80000000, /* destination MAC addr unknown */
GELIC_DESCR_RXLSTFBF = 0x40000000, /* last frame buffer */
GELIC_DESCR_RXIPCHK = 0x20000000, /* IP checksum performed */
GELIC_DESCR_RXTCPCHK = 0x10000000, /* TCP/UDP checksup performed */
GELIC_DESCR_RXWTPKT = 0x00C00000, /*
* wakeup trigger packet
* 01: Magic Packet (TM)
* 10: ARP packet
* 11: Multicast MAC addr
*/
GELIC_DESCR_RXVLNPKT = 0x00200000, /* VLAN packet */
/* bit 20..16 reserved */
GELIC_DESCR_RXRRECNUM = 0x0000ff00, /* reception receipt number */
/* bit 7..0 reserved */
}; };
/* interrupt mask */ #define GELIC_DESCR_DATA_STATUS_CHK_MASK \
#define GELIC_NET_TXINT (1L << (GELIC_NET_GDTDCEINT + 32)) (GELIC_DESCR_RXIPCHK | GELIC_DESCR_RXTCPCHK)
#define GELIC_NET_RXINT0 (1L << (GELIC_NET_GRFANMINT + 32)) /* TX descriptor data_status bits */
#define GELIC_NET_RXINT1 (1L << GELIC_NET_GDADCEINT) enum gelic_descr_tx_status {
#define GELIC_NET_RXINT (GELIC_NET_RXINT0 | GELIC_NET_RXINT1) GELIC_DESCR_TX_TAIL = 0x00000001, /* gelic treated this
* descriptor was end of
* a tx frame
*/
};
/* RX descriptor data_status bits */ /* RX descriptor data error bits */
#define GELIC_NET_RXDMADU 0x80000000 /* destination MAC addr unknown */ enum gelic_descr_rx_error {
#define GELIC_NET_RXLSTFBF 0x40000000 /* last frame buffer */ /* bit 31 reserved */
#define GELIC_NET_RXIPCHK 0x20000000 /* IP checksum performed */ GELIC_DESCR_RXALNERR = 0x40000000, /* alignement error 10/100M */
#define GELIC_NET_RXTCPCHK 0x10000000 /* TCP/UDP checksup performed */ GELIC_DESCR_RXOVERERR = 0x20000000, /* oversize error */
#define GELIC_NET_RXIPSPKT 0x08000000 /* IPsec packet */ GELIC_DESCR_RXRNTERR = 0x10000000, /* Runt error */
#define GELIC_NET_RXIPSAHPRT 0x04000000 /* IPsec AH protocol performed */ GELIC_DESCR_RXIPCHKERR = 0x08000000, /* IP checksum error */
#define GELIC_NET_RXIPSESPPRT 0x02000000 /* IPsec ESP protocol performed */ GELIC_DESCR_RXTCPCHKERR = 0x04000000, /* TCP/UDP checksum error */
#define GELIC_NET_RXSESPAH 0x01000000 /* GELIC_DESCR_RXDRPPKT = 0x00100000, /* drop packet */
* IPsec ESP protocol auth GELIC_DESCR_RXIPFMTERR = 0x00080000, /* IP packet format error */
* performed /* bit 18 reserved */
*/ GELIC_DESCR_RXDATAERR = 0x00020000, /* IP packet format error */
GELIC_DESCR_RXCALERR = 0x00010000, /* cariier extension length
#define GELIC_NET_RXWTPKT 0x00C00000 /* * error */
* wakeup trigger packet GELIC_DESCR_RXCREXERR = 0x00008000, /* carrier extention error */
* 01: Magic Packet (TM) GELIC_DESCR_RXMLTCST = 0x00004000, /* multicast address frame */
* 10: ARP packet /* bit 13..0 reserved */
* 11: Multicast MAC addr };
*/ #define GELIC_DESCR_DATA_ERROR_CHK_MASK \
#define GELIC_NET_RXVLNPKT 0x00200000 /* VLAN packet */ (GELIC_DESCR_RXIPCHKERR | GELIC_DESCR_RXTCPCHKERR)
/* bit 20..16 reserved */
#define GELIC_NET_RXRRECNUM 0x0000ff00 /* reception receipt number */ /* DMA command and status (RX and TX)*/
#define GELIC_NET_RXRRECNUM_SHIFT 8 enum gelic_descr_dma_status {
/* bit 7..0 reserved */ GELIC_DESCR_DMA_COMPLETE = 0x00000000, /* used in tx */
GELIC_DESCR_DMA_BUFFER_FULL = 0x00000000, /* used in rx */
#define GELIC_NET_TXDESC_TAIL 0 GELIC_DESCR_DMA_RESPONSE_ERROR = 0x10000000, /* used in rx, tx */
#define GELIC_NET_DATA_STATUS_CHK_MASK (GELIC_NET_RXIPCHK | GELIC_NET_RXTCPCHK) GELIC_DESCR_DMA_PROTECTION_ERROR = 0x20000000, /* used in rx, tx */
GELIC_DESCR_DMA_FRAME_END = 0x40000000, /* used in rx */
/* RX descriptor data_error bits */ GELIC_DESCR_DMA_FORCE_END = 0x50000000, /* used in rx, tx */
/* bit 31 reserved */ GELIC_DESCR_DMA_CARDOWNED = 0xa0000000, /* used in rx, tx */
#define GELIC_NET_RXALNERR 0x40000000 /* alignement error 10/100M */ GELIC_DESCR_DMA_NOT_IN_USE = 0xb0000000, /* any other value */
#define GELIC_NET_RXOVERERR 0x20000000 /* oversize error */ };
#define GELIC_NET_RXRNTERR 0x10000000 /* Runt error */
#define GELIC_NET_RXIPCHKERR 0x08000000 /* IP checksum error */
#define GELIC_NET_RXTCPCHKERR 0x04000000 /* TCP/UDP checksum error */
#define GELIC_NET_RXUMCHSP 0x02000000 /* unmatched sp on sp */
#define GELIC_NET_RXUMCHSPI 0x01000000 /* unmatched SPI on SAD */
#define GELIC_NET_RXUMCHSAD 0x00800000 /* unmatched SAD */
#define GELIC_NET_RXIPSAHERR 0x00400000 /* auth error on AH protocol
* processing */
#define GELIC_NET_RXIPSESPAHERR 0x00200000 /* auth error on ESP protocol
* processing */
#define GELIC_NET_RXDRPPKT 0x00100000 /* drop packet */
#define GELIC_NET_RXIPFMTERR 0x00080000 /* IP packet format error */
/* bit 18 reserved */
#define GELIC_NET_RXDATAERR 0x00020000 /* IP packet format error */
#define GELIC_NET_RXCALERR 0x00010000 /* cariier extension length
* error */
#define GELIC_NET_RXCREXERR 0x00008000 /* carrier extention error */
#define GELIC_NET_RXMLTCST 0x00004000 /* multicast address frame */
/* bit 13..0 reserved */
#define GELIC_NET_DATA_ERROR_CHK_MASK \
(GELIC_NET_RXIPCHKERR | GELIC_NET_RXTCPCHKERR)
#define GELIC_DESCR_DMA_STAT_MASK (0xf0000000)
/* tx descriptor command and status */ /* tx descriptor command and status */
#define GELIC_NET_DMAC_CMDSTAT_NOCS 0xa0080000 /* middle of frame */ enum gelic_descr_tx_dma_status {
#define GELIC_NET_DMAC_CMDSTAT_TCPCS 0xa00a0000 /* [19] */
#define GELIC_NET_DMAC_CMDSTAT_UDPCS 0xa00b0000 GELIC_DESCR_TX_DMA_IKE = 0x00080000, /* IPSEC off */
#define GELIC_NET_DMAC_CMDSTAT_END_FRAME 0x00040000 /* end of frame */ /* [18] */
GELIC_DESCR_TX_DMA_FRAME_TAIL = 0x00040000, /* last descriptor of
#define GELIC_NET_DMAC_CMDSTAT_RXDCEIS 0x00000002 /* descriptor chain end * the packet
* interrupt status */ */
/* [17..16] */
#define GELIC_NET_DMAC_CMDSTAT_CHAIN_END 0x00000002 /* RXDCEIS:DMA stopped */ GELIC_DESCR_TX_DMA_TCP_CHKSUM = 0x00020000, /* TCP packet */
#define GELIC_NET_DESCR_IND_PROC_SHIFT 28 GELIC_DESCR_TX_DMA_UDP_CHKSUM = 0x00030000, /* UDP packet */
#define GELIC_NET_DESCR_IND_PROC_MASKO 0x0fffffff GELIC_DESCR_TX_DMA_NO_CHKSUM = 0x00000000, /* no checksum */
/* [1] */
enum gelic_net_descr_status { GELIC_DESCR_TX_DMA_CHAIN_END = 0x00000002, /* DMA terminated
GELIC_NET_DESCR_COMPLETE = 0x00, /* used in tx */ * due to chain end
GELIC_NET_DESCR_BUFFER_FULL = 0x00, /* used in rx */ */
GELIC_NET_DESCR_RESPONSE_ERROR = 0x01, /* used in rx and tx */ };
GELIC_NET_DESCR_PROTECTION_ERROR = 0x02, /* used in rx and tx */
GELIC_NET_DESCR_FRAME_END = 0x04, /* used in rx */ #define GELIC_DESCR_DMA_CMD_NO_CHKSUM \
GELIC_NET_DESCR_FORCE_END = 0x05, /* used in rx and tx */ (GELIC_DESCR_DMA_CARDOWNED | GELIC_DESCR_TX_DMA_IKE | \
GELIC_NET_DESCR_CARDOWNED = 0x0a, /* used in rx and tx */ GELIC_DESCR_TX_DMA_NO_CHKSUM)
GELIC_NET_DESCR_NOT_IN_USE = 0x0b /* any other value */
#define GELIC_DESCR_DMA_CMD_TCP_CHKSUM \
(GELIC_DESCR_DMA_CARDOWNED | GELIC_DESCR_TX_DMA_IKE | \
GELIC_DESCR_TX_DMA_TCP_CHKSUM)
#define GELIC_DESCR_DMA_CMD_UDP_CHKSUM \
(GELIC_DESCR_DMA_CARDOWNED | GELIC_DESCR_TX_DMA_IKE | \
GELIC_DESCR_TX_DMA_UDP_CHKSUM)
enum gelic_descr_rx_dma_status {
/* [ 1 ] */
GELIC_DESCR_RX_DMA_CHAIN_END = 0x00000002, /* DMA terminated
* due to chain end
*/
}; };
/* for lv1_net_control */ /* for lv1_net_control */
#define GELIC_NET_GET_MAC_ADDRESS 0x0000000000000001 enum gelic_lv1_net_control_code {
#define GELIC_NET_GET_ETH_PORT_STATUS 0x0000000000000002 GELIC_LV1_GET_MAC_ADDRESS = 1,
#define GELIC_NET_SET_NEGOTIATION_MODE 0x0000000000000003 GELIC_LV1_GET_ETH_PORT_STATUS = 2,
#define GELIC_NET_GET_VLAN_ID 0x0000000000000004 GELIC_LV1_SET_NEGOTIATION_MODE = 3,
GELIC_LV1_GET_VLAN_ID = 4,
#define GELIC_NET_LINK_UP 0x0000000000000001 };
#define GELIC_NET_FULL_DUPLEX 0x0000000000000002
#define GELIC_NET_AUTO_NEG 0x0000000000000004 /* status returened from GET_ETH_PORT_STATUS */
#define GELIC_NET_SPEED_10 0x0000000000000010 enum gelic_lv1_ether_port_status {
#define GELIC_NET_SPEED_100 0x0000000000000020 GELIC_LV1_ETHER_LINK_UP = 0x0000000000000001L,
#define GELIC_NET_SPEED_1000 0x0000000000000040 GELIC_LV1_ETHER_FULL_DUPLEX = 0x0000000000000002L,
GELIC_LV1_ETHER_AUTO_NEG = 0x0000000000000004L,
#define GELIC_NET_VLAN_ALL 0x0000000000000001
#define GELIC_NET_VLAN_WIRED 0x0000000000000002 GELIC_LV1_ETHER_SPEED_10 = 0x0000000000000010L,
#define GELIC_NET_VLAN_WIRELESS 0x0000000000000003 GELIC_LV1_ETHER_SPEED_100 = 0x0000000000000020L,
#define GELIC_NET_VLAN_PSP 0x0000000000000004 GELIC_LV1_ETHER_SPEED_1000 = 0x0000000000000040L,
#define GELIC_NET_VLAN_PORT0 0x0000000000000010 GELIC_LV1_ETHER_SPEED_MASK = 0x0000000000000070L
#define GELIC_NET_VLAN_PORT1 0x0000000000000011 };
#define GELIC_NET_VLAN_PORT2 0x0000000000000012
#define GELIC_NET_VLAN_DAEMON_CLIENT_BSS 0x0000000000000013 enum gelic_lv1_vlan_index {
#define GELIC_NET_VLAN_LIBERO_CLIENT_BSS 0x0000000000000014 /* for outgoing packets */
#define GELIC_NET_VLAN_NO_ENTRY -6 GELIC_LV1_VLAN_TX_ETHERNET = 0x0000000000000002L,
GELIC_LV1_VLAN_TX_WIRELESS = 0x0000000000000003L,
#define GELIC_NET_PORT 2 /* for port status */ /* for incoming packets */
GELIC_LV1_VLAN_RX_ETHERNET = 0x0000000000000012L,
GELIC_LV1_VLAN_RX_WIRELESS = 0x0000000000000013L
};
/* size of hardware part of gelic descriptor */ /* size of hardware part of gelic descriptor */
#define GELIC_NET_DESCR_SIZE (32) #define GELIC_DESCR_SIZE (32)
struct gelic_net_descr { struct gelic_descr {
/* as defined by the hardware */ /* as defined by the hardware */
__be32 buf_addr; __be32 buf_addr;
__be32 buf_size; __be32 buf_size;
...@@ -181,18 +220,18 @@ struct gelic_net_descr { ...@@ -181,18 +220,18 @@ struct gelic_net_descr {
/* used in the driver */ /* used in the driver */
struct sk_buff *skb; struct sk_buff *skb;
dma_addr_t bus_addr; dma_addr_t bus_addr;
struct gelic_net_descr *next; struct gelic_descr *next;
struct gelic_net_descr *prev; struct gelic_descr *prev;
struct vlan_ethhdr vlan; struct vlan_ethhdr vlan;
} __attribute__((aligned(32))); } __attribute__((aligned(32)));
struct gelic_net_descr_chain { struct gelic_descr_chain {
/* we walk from tail to head */ /* we walk from tail to head */
struct gelic_net_descr *head; struct gelic_descr *head;
struct gelic_net_descr *tail; struct gelic_descr *tail;
}; };
struct gelic_net_card { struct gelic_card {
struct net_device *netdev; struct net_device *netdev;
struct napi_struct napi; struct napi_struct napi;
/* /*
...@@ -207,8 +246,8 @@ struct gelic_net_card { ...@@ -207,8 +246,8 @@ struct gelic_net_card {
u32 vlan_id[GELIC_NET_VLAN_MAX]; u32 vlan_id[GELIC_NET_VLAN_MAX];
int vlan_index; int vlan_index;
struct gelic_net_descr_chain tx_chain; struct gelic_descr_chain tx_chain;
struct gelic_net_descr_chain rx_chain; struct gelic_descr_chain rx_chain;
int rx_dma_restart_required; int rx_dma_restart_required;
/* gurad dmac descriptor chain*/ /* gurad dmac descriptor chain*/
spinlock_t chain_lock; spinlock_t chain_lock;
...@@ -222,8 +261,8 @@ struct gelic_net_card { ...@@ -222,8 +261,8 @@ struct gelic_net_card {
atomic_t tx_timeout_task_counter; atomic_t tx_timeout_task_counter;
wait_queue_head_t waitq; wait_queue_head_t waitq;
struct gelic_net_descr *tx_top, *rx_top; struct gelic_descr *tx_top, *rx_top;
struct gelic_net_descr descr[0]; struct gelic_descr descr[0];
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册