Skip to content

Commit f23223f

Browse files
claudiu-mdavem330
authored andcommitted
gianfar: Use ndev, more Rx path cleanup
Use "ndev" instead of "dev", as the rx queue back pointer to a net_device struct, to avoid name clashing with a "struct device" reference. This prepares the addition of a "struct device" back pointer to the rx queue structure. Remove duplicated rxq registration in the process. Move napi_gro_receive() outside gfar_process_frame(). Signed-off-by: Claudiu Manoil <claudiu.manoil@freescale.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f966082 commit f23223f

File tree

2 files changed

+26
-32
lines changed

2 files changed

+26
-32
lines changed

drivers/net/ethernet/freescale/gianfar.c

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ static void gfar_netpoll(struct net_device *dev);
141141
#endif
142142
int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit);
143143
static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue);
144-
static void gfar_process_frame(struct net_device *dev, struct sk_buff *skb,
145-
struct napi_struct *napi);
144+
static void gfar_process_frame(struct net_device *ndev, struct sk_buff *skb);
146145
static void gfar_halt_nodisable(struct gfar_private *priv);
147146
static void gfar_clear_exact_match(struct net_device *dev);
148147
static void gfar_set_mac_for_addr(struct net_device *dev, int num,
@@ -262,7 +261,7 @@ static int gfar_alloc_skb_resources(struct net_device *ndev)
262261
rx_queue = priv->rx_queue[i];
263262
rx_queue->rx_bd_base = vaddr;
264263
rx_queue->rx_bd_dma_base = addr;
265-
rx_queue->dev = ndev;
264+
rx_queue->ndev = ndev;
266265
addr += sizeof(struct rxbd8) * rx_queue->rx_ring_size;
267266
vaddr += sizeof(struct rxbd8) * rx_queue->rx_ring_size;
268267
}
@@ -593,7 +592,7 @@ static int gfar_alloc_rx_queues(struct gfar_private *priv)
593592

594593
priv->rx_queue[i]->rx_skbuff = NULL;
595594
priv->rx_queue[i]->qindex = i;
596-
priv->rx_queue[i]->dev = priv->ndev;
595+
priv->rx_queue[i]->ndev = priv->ndev;
597596
}
598597
return 0;
599598
}
@@ -1913,7 +1912,7 @@ static void free_skb_tx_queue(struct gfar_priv_tx_q *tx_queue)
19131912
static void free_skb_rx_queue(struct gfar_priv_rx_q *rx_queue)
19141913
{
19151914
struct rxbd8 *rxbdp;
1916-
struct gfar_private *priv = netdev_priv(rx_queue->dev);
1915+
struct gfar_private *priv = netdev_priv(rx_queue->ndev);
19171916
int i;
19181917

19191918
rxbdp = rx_queue->rx_bd_base;
@@ -2709,17 +2708,17 @@ static struct sk_buff *gfar_new_skb(struct net_device *ndev,
27092708

27102709
static void gfar_rx_alloc_err(struct gfar_priv_rx_q *rx_queue)
27112710
{
2712-
struct gfar_private *priv = netdev_priv(rx_queue->dev);
2711+
struct gfar_private *priv = netdev_priv(rx_queue->ndev);
27132712
struct gfar_extra_stats *estats = &priv->extra_stats;
27142713

2715-
netdev_err(rx_queue->dev, "Can't alloc RX buffers\n");
2714+
netdev_err(rx_queue->ndev, "Can't alloc RX buffers\n");
27162715
atomic64_inc(&estats->rx_alloc_err);
27172716
}
27182717

27192718
static void gfar_alloc_rx_buffs(struct gfar_priv_rx_q *rx_queue,
27202719
int alloc_cnt)
27212720
{
2722-
struct net_device *ndev = rx_queue->dev;
2721+
struct net_device *ndev = rx_queue->ndev;
27232722
struct rxbd8 *bdp, *base;
27242723
dma_addr_t bufaddr;
27252724
int i;
@@ -2756,10 +2755,10 @@ static void gfar_alloc_rx_buffs(struct gfar_priv_rx_q *rx_queue,
27562755
rx_queue->next_to_use = i;
27572756
}
27582757

2759-
static void count_errors(u32 lstatus, struct net_device *dev)
2758+
static void count_errors(u32 lstatus, struct net_device *ndev)
27602759
{
2761-
struct gfar_private *priv = netdev_priv(dev);
2762-
struct net_device_stats *stats = &dev->stats;
2760+
struct gfar_private *priv = netdev_priv(ndev);
2761+
struct net_device_stats *stats = &ndev->stats;
27632762
struct gfar_extra_stats *estats = &priv->extra_stats;
27642763

27652764
/* If the packet was truncated, none of the other errors matter */
@@ -2854,10 +2853,9 @@ static inline void gfar_rx_checksum(struct sk_buff *skb, struct rxfcb *fcb)
28542853
}
28552854

28562855
/* gfar_process_frame() -- handle one incoming packet if skb isn't NULL. */
2857-
static void gfar_process_frame(struct net_device *dev, struct sk_buff *skb,
2858-
struct napi_struct *napi)
2856+
static void gfar_process_frame(struct net_device *ndev, struct sk_buff *skb)
28592857
{
2860-
struct gfar_private *priv = netdev_priv(dev);
2858+
struct gfar_private *priv = netdev_priv(ndev);
28612859
struct rxfcb *fcb = NULL;
28622860

28632861
/* fcb is at the beginning if exists */
@@ -2866,10 +2864,8 @@ static void gfar_process_frame(struct net_device *dev, struct sk_buff *skb,
28662864
/* Remove the FCB from the skb
28672865
* Remove the padded bytes, if there are any
28682866
*/
2869-
if (priv->uses_rxfcb) {
2870-
skb_record_rx_queue(skb, fcb->rq);
2867+
if (priv->uses_rxfcb)
28712868
skb_pull(skb, GMAC_FCB_LEN);
2872-
}
28732869

28742870
/* Get receive timestamp from the skb */
28752871
if (priv->hwts_rx_en) {
@@ -2883,24 +2879,20 @@ static void gfar_process_frame(struct net_device *dev, struct sk_buff *skb,
28832879
if (priv->padding)
28842880
skb_pull(skb, priv->padding);
28852881

2886-
if (dev->features & NETIF_F_RXCSUM)
2882+
if (ndev->features & NETIF_F_RXCSUM)
28872883
gfar_rx_checksum(skb, fcb);
28882884

28892885
/* Tell the skb what kind of packet this is */
2890-
skb->protocol = eth_type_trans(skb, dev);
2886+
skb->protocol = eth_type_trans(skb, ndev);
28912887

28922888
/* There's need to check for NETIF_F_HW_VLAN_CTAG_RX here.
28932889
* Even if vlan rx accel is disabled, on some chips
28942890
* RXFCB_VLN is pseudo randomly set.
28952891
*/
2896-
if (dev->features & NETIF_F_HW_VLAN_CTAG_RX &&
2892+
if (ndev->features & NETIF_F_HW_VLAN_CTAG_RX &&
28972893
be16_to_cpu(fcb->flags) & RXFCB_VLN)
28982894
__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
28992895
be16_to_cpu(fcb->vlctl));
2900-
2901-
/* Send the packet up the stack */
2902-
napi_gro_receive(napi, skb);
2903-
29042896
}
29052897

29062898
/* gfar_clean_rx_ring() -- Processes each frame in the rx ring
@@ -2909,12 +2901,12 @@ static void gfar_process_frame(struct net_device *dev, struct sk_buff *skb,
29092901
*/
29102902
int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit)
29112903
{
2912-
struct net_device *dev = rx_queue->dev;
2904+
struct net_device *ndev = rx_queue->ndev;
29132905
struct rxbd8 *bdp, *base;
29142906
struct sk_buff *skb;
29152907
int i, howmany = 0;
29162908
int cleaned_cnt = gfar_rxbd_unused(rx_queue);
2917-
struct gfar_private *priv = netdev_priv(dev);
2909+
struct gfar_private *priv = netdev_priv(ndev);
29182910

29192911
/* Get the first full descriptor */
29202912
base = rx_queue->rx_bd_base;
@@ -2948,7 +2940,7 @@ int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit)
29482940

29492941
if (unlikely(!(lstatus & BD_LFLAG(RXBD_LAST)) ||
29502942
(lstatus & BD_LFLAG(RXBD_ERR)))) {
2951-
count_errors(lstatus, dev);
2943+
count_errors(lstatus, ndev);
29522944

29532945
/* discard faulty buffer */
29542946
dev_kfree_skb(skb);
@@ -2965,11 +2957,13 @@ int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit)
29652957
skb_put(skb, pkt_len);
29662958
rx_queue->stats.rx_bytes += pkt_len;
29672959
skb_record_rx_queue(skb, rx_queue->qindex);
2968-
gfar_process_frame(dev, skb,
2969-
&rx_queue->grp->napi_rx);
2960+
gfar_process_frame(ndev, skb);
2961+
2962+
/* Send the packet up the stack */
2963+
napi_gro_receive(&rx_queue->grp->napi_rx, skb);
29702964

29712965
} else {
2972-
netif_warn(priv, rx_err, dev, "Missing skb!\n");
2966+
netif_warn(priv, rx_err, ndev, "Missing skb!\n");
29732967
rx_queue->stats.rx_dropped++;
29742968
atomic64_inc(&priv->extra_stats.rx_skbmissing);
29752969
}

drivers/net/ethernet/freescale/gianfar.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ struct rx_q_stats {
10221022
* @next_to_use: index of the next buffer to be alloc'd
10231023
* @next_to_clean: index of the next buffer to be cleaned
10241024
* @qindex: index of this queue
1025-
* @dev: back pointer to the dev structure
1025+
* @ndev: back pointer to net_device
10261026
* @rx_ring_size: Rx ring size
10271027
* @rxcoalescing: enable/disable rx-coalescing
10281028
* @rxic: receive interrupt coalescing vlaue
@@ -1031,7 +1031,7 @@ struct rx_q_stats {
10311031
struct gfar_priv_rx_q {
10321032
struct sk_buff **rx_skbuff __aligned(SMP_CACHE_BYTES);
10331033
struct rxbd8 *rx_bd_base;
1034-
struct net_device *dev;
1034+
struct net_device *ndev;
10351035
struct gfar_priv_grp *grp;
10361036
u16 rx_ring_size;
10371037
u16 qindex;

0 commit comments

Comments
 (0)