aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/marvell/mvneta.c
diff options
context:
space:
mode:
authorwilly tarreau <w@1wt.eu>2014-01-16 02:20:14 -0500
committerDavid S. Miller <davem@davemloft.net>2014-01-16 18:15:42 -0500
commit5428213c042b572d10418fe22cc3c1c682631cad (patch)
treee25bdf668486a6cf811fc25ad656b7173325a69d /drivers/net/ethernet/marvell/mvneta.c
parenta1a65ab18a9da16e322e88305324c38cd797caa9 (diff)
net: mvneta: simplify access to the rx descriptor status
At several places, we already know the value of the rx status but we call functions which dereference the pointer again to get it and don't need the descriptor for anything else. Simplify this task by replacing the rx desc pointer by the status word itself. Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Cc: Gregory CLEMENT <gregory.clement@free-electrons.com> Tested-by: Arnaud Ebalard <arno@natisbad.org> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/marvell/mvneta.c')
-rw-r--r--drivers/net/ethernet/marvell/mvneta.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index eccafd13b882..aa3a4f7c3f7c 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -528,14 +528,14 @@ struct rtnl_link_stats64 *mvneta_get_stats64(struct net_device *dev,
528 528
529/* Rx descriptors helper methods */ 529/* Rx descriptors helper methods */
530 530
531/* Checks whether the given RX descriptor is both the first and the 531/* Checks whether the RX descriptor having this status is both the first
532 * last descriptor for the RX packet. Each RX packet is currently 532 * and the last descriptor for the RX packet. Each RX packet is currently
533 * received through a single RX descriptor, so not having each RX 533 * received through a single RX descriptor, so not having each RX
534 * descriptor with its first and last bits set is an error 534 * descriptor with its first and last bits set is an error
535 */ 535 */
536static int mvneta_rxq_desc_is_first_last(struct mvneta_rx_desc *desc) 536static int mvneta_rxq_desc_is_first_last(u32 status)
537{ 537{
538 return (desc->status & MVNETA_RXD_FIRST_LAST_DESC) == 538 return (status & MVNETA_RXD_FIRST_LAST_DESC) ==
539 MVNETA_RXD_FIRST_LAST_DESC; 539 MVNETA_RXD_FIRST_LAST_DESC;
540} 540}
541 541
@@ -1234,10 +1234,10 @@ static void mvneta_rx_error(struct mvneta_port *pp,
1234{ 1234{
1235 u32 status = rx_desc->status; 1235 u32 status = rx_desc->status;
1236 1236
1237 if (!mvneta_rxq_desc_is_first_last(rx_desc)) { 1237 if (!mvneta_rxq_desc_is_first_last(status)) {
1238 netdev_err(pp->dev, 1238 netdev_err(pp->dev,
1239 "bad rx status %08x (buffer oversize), size=%d\n", 1239 "bad rx status %08x (buffer oversize), size=%d\n",
1240 rx_desc->status, rx_desc->data_size); 1240 status, rx_desc->data_size);
1241 return; 1241 return;
1242 } 1242 }
1243 1243
@@ -1261,13 +1261,12 @@ static void mvneta_rx_error(struct mvneta_port *pp,
1261 } 1261 }
1262} 1262}
1263 1263
1264/* Handle RX checksum offload */ 1264/* Handle RX checksum offload based on the descriptor's status */
1265static void mvneta_rx_csum(struct mvneta_port *pp, 1265static void mvneta_rx_csum(struct mvneta_port *pp, u32 status,
1266 struct mvneta_rx_desc *rx_desc,
1267 struct sk_buff *skb) 1266 struct sk_buff *skb)
1268{ 1267{
1269 if ((rx_desc->status & MVNETA_RXD_L3_IP4) && 1268 if ((status & MVNETA_RXD_L3_IP4) &&
1270 (rx_desc->status & MVNETA_RXD_L4_CSUM_OK)) { 1269 (status & MVNETA_RXD_L4_CSUM_OK)) {
1271 skb->csum = 0; 1270 skb->csum = 0;
1272 skb->ip_summed = CHECKSUM_UNNECESSARY; 1271 skb->ip_summed = CHECKSUM_UNNECESSARY;
1273 return; 1272 return;
@@ -1449,7 +1448,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
1449 rx_status = rx_desc->status; 1448 rx_status = rx_desc->status;
1450 skb = (struct sk_buff *)rx_desc->buf_cookie; 1449 skb = (struct sk_buff *)rx_desc->buf_cookie;
1451 1450
1452 if (!mvneta_rxq_desc_is_first_last(rx_desc) || 1451 if (!mvneta_rxq_desc_is_first_last(rx_status) ||
1453 (rx_status & MVNETA_RXD_ERR_SUMMARY)) { 1452 (rx_status & MVNETA_RXD_ERR_SUMMARY)) {
1454 dev->stats.rx_errors++; 1453 dev->stats.rx_errors++;
1455 mvneta_rx_error(pp, rx_desc); 1454 mvneta_rx_error(pp, rx_desc);
@@ -1472,7 +1471,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
1472 1471
1473 skb->protocol = eth_type_trans(skb, dev); 1472 skb->protocol = eth_type_trans(skb, dev);
1474 1473
1475 mvneta_rx_csum(pp, rx_desc, skb); 1474 mvneta_rx_csum(pp, rx_status, skb);
1476 1475
1477 napi_gro_receive(&pp->napi, skb); 1476 napi_gro_receive(&pp->napi, skb);
1478 1477