aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuresh Reddy <suresh.reddy@emulex.com>2014-01-15 02:53:38 -0500
committerDavid S. Miller <davem@davemloft.net>2014-01-15 18:52:03 -0500
commit0b0ef1d027008f019ced2d69e343bb1257326b12 (patch)
treee7f10fae3f287b5fd5d4380fcd31616f70c8d83f
parentf3effb45c39e0945adeda7e0e75a4450e45f9b20 (diff)
be2net: do not use frag index in the RX-compl entry
Instead, use the tail of the RXQ to pick the associated RXQ entry This fix is required in preparation for supporting RXQ lengths greater than 1K. For such queues, the frag index in the RX-compl entry is not valid as it is only a 10 bit entry not capable of addressing RXQs longer than 1K. Signed-off-by: Suresh Reddy <suresh.reddy@emulex.com> Signed-off-by: Sathya Perla <sathya.perla@emulex.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/emulex/benet/be.h1
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c30
2 files changed, 9 insertions, 22 deletions
diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h
index b74d81d1a755..7f00baee1bc8 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -283,7 +283,6 @@ struct be_rx_compl_info {
283 u32 rss_hash; 283 u32 rss_hash;
284 u16 vlan_tag; 284 u16 vlan_tag;
285 u16 pkt_size; 285 u16 pkt_size;
286 u16 rxq_idx;
287 u16 port; 286 u16 port;
288 u8 vlanf; 287 u8 vlanf;
289 u8 num_rcvd; 288 u8 num_rcvd;
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 9c90a87052d5..9704a1b23cef 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -1442,12 +1442,12 @@ static inline bool csum_passed(struct be_rx_compl_info *rxcp)
1442 (rxcp->ip_csum || rxcp->ipv6); 1442 (rxcp->ip_csum || rxcp->ipv6);
1443} 1443}
1444 1444
1445static struct be_rx_page_info *get_rx_page_info(struct be_rx_obj *rxo, 1445static struct be_rx_page_info *get_rx_page_info(struct be_rx_obj *rxo)
1446 u16 frag_idx)
1447{ 1446{
1448 struct be_adapter *adapter = rxo->adapter; 1447 struct be_adapter *adapter = rxo->adapter;
1449 struct be_rx_page_info *rx_page_info; 1448 struct be_rx_page_info *rx_page_info;
1450 struct be_queue_info *rxq = &rxo->q; 1449 struct be_queue_info *rxq = &rxo->q;
1450 u16 frag_idx = rxq->tail;
1451 1451
1452 rx_page_info = &rxo->page_info_tbl[frag_idx]; 1452 rx_page_info = &rxo->page_info_tbl[frag_idx];
1453 BUG_ON(!rx_page_info->page); 1453 BUG_ON(!rx_page_info->page);
@@ -1459,6 +1459,7 @@ static struct be_rx_page_info *get_rx_page_info(struct be_rx_obj *rxo,
1459 rx_page_info->last_page_user = false; 1459 rx_page_info->last_page_user = false;
1460 } 1460 }
1461 1461
1462 queue_tail_inc(rxq);
1462 atomic_dec(&rxq->used); 1463 atomic_dec(&rxq->used);
1463 return rx_page_info; 1464 return rx_page_info;
1464} 1465}
@@ -1467,15 +1468,13 @@ static struct be_rx_page_info *get_rx_page_info(struct be_rx_obj *rxo,
1467static void be_rx_compl_discard(struct be_rx_obj *rxo, 1468static void be_rx_compl_discard(struct be_rx_obj *rxo,
1468 struct be_rx_compl_info *rxcp) 1469 struct be_rx_compl_info *rxcp)
1469{ 1470{
1470 struct be_queue_info *rxq = &rxo->q;
1471 struct be_rx_page_info *page_info; 1471 struct be_rx_page_info *page_info;
1472 u16 i, num_rcvd = rxcp->num_rcvd; 1472 u16 i, num_rcvd = rxcp->num_rcvd;
1473 1473
1474 for (i = 0; i < num_rcvd; i++) { 1474 for (i = 0; i < num_rcvd; i++) {
1475 page_info = get_rx_page_info(rxo, rxcp->rxq_idx); 1475 page_info = get_rx_page_info(rxo);
1476 put_page(page_info->page); 1476 put_page(page_info->page);
1477 memset(page_info, 0, sizeof(*page_info)); 1477 memset(page_info, 0, sizeof(*page_info));
1478 index_inc(&rxcp->rxq_idx, rxq->len);
1479 } 1478 }
1480} 1479}
1481 1480
@@ -1486,13 +1485,12 @@ static void be_rx_compl_discard(struct be_rx_obj *rxo,
1486static void skb_fill_rx_data(struct be_rx_obj *rxo, struct sk_buff *skb, 1485static void skb_fill_rx_data(struct be_rx_obj *rxo, struct sk_buff *skb,
1487 struct be_rx_compl_info *rxcp) 1486 struct be_rx_compl_info *rxcp)
1488{ 1487{
1489 struct be_queue_info *rxq = &rxo->q;
1490 struct be_rx_page_info *page_info; 1488 struct be_rx_page_info *page_info;
1491 u16 i, j; 1489 u16 i, j;
1492 u16 hdr_len, curr_frag_len, remaining; 1490 u16 hdr_len, curr_frag_len, remaining;
1493 u8 *start; 1491 u8 *start;
1494 1492
1495 page_info = get_rx_page_info(rxo, rxcp->rxq_idx); 1493 page_info = get_rx_page_info(rxo);
1496 start = page_address(page_info->page) + page_info->page_offset; 1494 start = page_address(page_info->page) + page_info->page_offset;
1497 prefetch(start); 1495 prefetch(start);
1498 1496
@@ -1526,10 +1524,9 @@ static void skb_fill_rx_data(struct be_rx_obj *rxo, struct sk_buff *skb,
1526 } 1524 }
1527 1525
1528 /* More frags present for this completion */ 1526 /* More frags present for this completion */
1529 index_inc(&rxcp->rxq_idx, rxq->len);
1530 remaining = rxcp->pkt_size - curr_frag_len; 1527 remaining = rxcp->pkt_size - curr_frag_len;
1531 for (i = 1, j = 0; i < rxcp->num_rcvd; i++) { 1528 for (i = 1, j = 0; i < rxcp->num_rcvd; i++) {
1532 page_info = get_rx_page_info(rxo, rxcp->rxq_idx); 1529 page_info = get_rx_page_info(rxo);
1533 curr_frag_len = min(remaining, rx_frag_size); 1530 curr_frag_len = min(remaining, rx_frag_size);
1534 1531
1535 /* Coalesce all frags from the same physical page in one slot */ 1532 /* Coalesce all frags from the same physical page in one slot */
@@ -1550,7 +1547,6 @@ static void skb_fill_rx_data(struct be_rx_obj *rxo, struct sk_buff *skb,
1550 skb->data_len += curr_frag_len; 1547 skb->data_len += curr_frag_len;
1551 skb->truesize += rx_frag_size; 1548 skb->truesize += rx_frag_size;
1552 remaining -= curr_frag_len; 1549 remaining -= curr_frag_len;
1553 index_inc(&rxcp->rxq_idx, rxq->len);
1554 page_info->page = NULL; 1550 page_info->page = NULL;
1555 } 1551 }
1556 BUG_ON(j > MAX_SKB_FRAGS); 1552 BUG_ON(j > MAX_SKB_FRAGS);
@@ -1598,7 +1594,6 @@ static void be_rx_compl_process_gro(struct be_rx_obj *rxo,
1598 struct be_adapter *adapter = rxo->adapter; 1594 struct be_adapter *adapter = rxo->adapter;
1599 struct be_rx_page_info *page_info; 1595 struct be_rx_page_info *page_info;
1600 struct sk_buff *skb = NULL; 1596 struct sk_buff *skb = NULL;
1601 struct be_queue_info *rxq = &rxo->q;
1602 u16 remaining, curr_frag_len; 1597 u16 remaining, curr_frag_len;
1603 u16 i, j; 1598 u16 i, j;
1604 1599
@@ -1610,7 +1605,7 @@ static void be_rx_compl_process_gro(struct be_rx_obj *rxo,
1610 1605
1611 remaining = rxcp->pkt_size; 1606 remaining = rxcp->pkt_size;
1612 for (i = 0, j = -1; i < rxcp->num_rcvd; i++) { 1607 for (i = 0, j = -1; i < rxcp->num_rcvd; i++) {
1613 page_info = get_rx_page_info(rxo, rxcp->rxq_idx); 1608 page_info = get_rx_page_info(rxo);
1614 1609
1615 curr_frag_len = min(remaining, rx_frag_size); 1610 curr_frag_len = min(remaining, rx_frag_size);
1616 1611
@@ -1628,7 +1623,6 @@ static void be_rx_compl_process_gro(struct be_rx_obj *rxo,
1628 skb_frag_size_add(&skb_shinfo(skb)->frags[j], curr_frag_len); 1623 skb_frag_size_add(&skb_shinfo(skb)->frags[j], curr_frag_len);
1629 skb->truesize += rx_frag_size; 1624 skb->truesize += rx_frag_size;
1630 remaining -= curr_frag_len; 1625 remaining -= curr_frag_len;
1631 index_inc(&rxcp->rxq_idx, rxq->len);
1632 memset(page_info, 0, sizeof(*page_info)); 1626 memset(page_info, 0, sizeof(*page_info));
1633 } 1627 }
1634 BUG_ON(j > MAX_SKB_FRAGS); 1628 BUG_ON(j > MAX_SKB_FRAGS);
@@ -1663,8 +1657,6 @@ static void be_parse_rx_compl_v1(struct be_eth_rx_compl *compl,
1663 AMAP_GET_BITS(struct amap_eth_rx_compl_v1, l4_cksm, compl); 1657 AMAP_GET_BITS(struct amap_eth_rx_compl_v1, l4_cksm, compl);
1664 rxcp->ipv6 = 1658 rxcp->ipv6 =
1665 AMAP_GET_BITS(struct amap_eth_rx_compl_v1, ip_version, compl); 1659 AMAP_GET_BITS(struct amap_eth_rx_compl_v1, ip_version, compl);
1666 rxcp->rxq_idx =
1667 AMAP_GET_BITS(struct amap_eth_rx_compl_v1, fragndx, compl);
1668 rxcp->num_rcvd = 1660 rxcp->num_rcvd =
1669 AMAP_GET_BITS(struct amap_eth_rx_compl_v1, numfrags, compl); 1661 AMAP_GET_BITS(struct amap_eth_rx_compl_v1, numfrags, compl);
1670 rxcp->pkt_type = 1662 rxcp->pkt_type =
@@ -1695,8 +1687,6 @@ static void be_parse_rx_compl_v0(struct be_eth_rx_compl *compl,
1695 AMAP_GET_BITS(struct amap_eth_rx_compl_v0, l4_cksm, compl); 1687 AMAP_GET_BITS(struct amap_eth_rx_compl_v0, l4_cksm, compl);
1696 rxcp->ipv6 = 1688 rxcp->ipv6 =
1697 AMAP_GET_BITS(struct amap_eth_rx_compl_v0, ip_version, compl); 1689 AMAP_GET_BITS(struct amap_eth_rx_compl_v0, ip_version, compl);
1698 rxcp->rxq_idx =
1699 AMAP_GET_BITS(struct amap_eth_rx_compl_v0, fragndx, compl);
1700 rxcp->num_rcvd = 1690 rxcp->num_rcvd =
1701 AMAP_GET_BITS(struct amap_eth_rx_compl_v0, numfrags, compl); 1691 AMAP_GET_BITS(struct amap_eth_rx_compl_v0, numfrags, compl);
1702 rxcp->pkt_type = 1692 rxcp->pkt_type =
@@ -1914,7 +1904,6 @@ static void be_rx_cq_clean(struct be_rx_obj *rxo)
1914 struct be_rx_compl_info *rxcp; 1904 struct be_rx_compl_info *rxcp;
1915 struct be_adapter *adapter = rxo->adapter; 1905 struct be_adapter *adapter = rxo->adapter;
1916 int flush_wait = 0; 1906 int flush_wait = 0;
1917 u16 tail;
1918 1907
1919 /* Consume pending rx completions. 1908 /* Consume pending rx completions.
1920 * Wait for the flush completion (identified by zero num_rcvd) 1909 * Wait for the flush completion (identified by zero num_rcvd)
@@ -1947,9 +1936,8 @@ static void be_rx_cq_clean(struct be_rx_obj *rxo)
1947 be_cq_notify(adapter, rx_cq->id, false, 0); 1936 be_cq_notify(adapter, rx_cq->id, false, 0);
1948 1937
1949 /* Then free posted rx buffers that were not used */ 1938 /* Then free posted rx buffers that were not used */
1950 tail = (rxq->head + rxq->len - atomic_read(&rxq->used)) % rxq->len; 1939 while (atomic_read(&rxq->used) > 0) {
1951 for (; atomic_read(&rxq->used) > 0; index_inc(&tail, rxq->len)) { 1940 page_info = get_rx_page_info(rxo);
1952 page_info = get_rx_page_info(rxo, tail);
1953 put_page(page_info->page); 1941 put_page(page_info->page);
1954 memset(page_info, 0, sizeof(*page_info)); 1942 memset(page_info, 0, sizeof(*page_info));
1955 } 1943 }