Skip to content

Commit 06b3e35

Browse files
tlfalcondavem330
authored andcommitted
ibmvnic: Update TX and TX completion routines
Update TX and TX completion routines to account for TX pool restructuring. TX routine first chooses the pool depending on whether a packet is GSO or not, then uses it accordingly. For the completion routine to know which pool it needs to use, set the most significant bit of the correlator index to one if the packet uses the TSO pool. On completion, unset the bit and use the correlator index to release the buffer pool entry. Signed-off-by: Thomas Falcon <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3205306 commit 06b3e35

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
lines changed

drivers/net/ethernet/ibm/ibmvnic.c

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,29 +1414,22 @@ static int ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
14141414
ret = NETDEV_TX_OK;
14151415
goto out;
14161416
}
1417+
if (skb_is_gso(skb))
1418+
tx_pool = &adapter->tso_pool[queue_num];
1419+
else
1420+
tx_pool = &adapter->tx_pool[queue_num];
14171421

1418-
tx_pool = &adapter->tx_pool[queue_num];
14191422
tx_scrq = adapter->tx_scrq[queue_num];
14201423
txq = netdev_get_tx_queue(netdev, skb_get_queue_mapping(skb));
14211424
handle_array = (u64 *)((u8 *)(adapter->login_rsp_buf) +
14221425
be32_to_cpu(adapter->login_rsp_buf->off_txsubm_subcrqs));
14231426

14241427
index = tx_pool->free_map[tx_pool->consumer_index];
14251428

1426-
if (skb_is_gso(skb)) {
1427-
offset = tx_pool->tso_index * IBMVNIC_TSO_BUF_SZ;
1428-
dst = tx_pool->tso_ltb.buff + offset;
1429-
memset(dst, 0, IBMVNIC_TSO_BUF_SZ);
1430-
data_dma_addr = tx_pool->tso_ltb.addr + offset;
1431-
tx_pool->tso_index++;
1432-
if (tx_pool->tso_index == IBMVNIC_TSO_BUFS)
1433-
tx_pool->tso_index = 0;
1434-
} else {
1435-
offset = index * (adapter->req_mtu + VLAN_HLEN);
1436-
dst = tx_pool->long_term_buff.buff + offset;
1437-
memset(dst, 0, adapter->req_mtu + VLAN_HLEN);
1438-
data_dma_addr = tx_pool->long_term_buff.addr + offset;
1439-
}
1429+
offset = index * tx_pool->buf_size;
1430+
dst = tx_pool->long_term_buff.buff + offset;
1431+
memset(dst, 0, tx_pool->buf_size);
1432+
data_dma_addr = tx_pool->long_term_buff.addr + offset;
14401433

14411434
if (skb_shinfo(skb)->nr_frags) {
14421435
int cur, i;
@@ -1459,8 +1452,7 @@ static int ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
14591452
}
14601453

14611454
tx_pool->consumer_index =
1462-
(tx_pool->consumer_index + 1) %
1463-
adapter->req_tx_entries_per_subcrq;
1455+
(tx_pool->consumer_index + 1) % tx_pool->num_buffers;
14641456

14651457
tx_buff = &tx_pool->tx_buff[index];
14661458
tx_buff->skb = skb;
@@ -1476,11 +1468,13 @@ static int ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
14761468
tx_crq.v1.n_crq_elem = 1;
14771469
tx_crq.v1.n_sge = 1;
14781470
tx_crq.v1.flags1 = IBMVNIC_TX_COMP_NEEDED;
1479-
tx_crq.v1.correlator = cpu_to_be32(index);
1471+
14801472
if (skb_is_gso(skb))
1481-
tx_crq.v1.dma_reg = cpu_to_be16(tx_pool->tso_ltb.map_id);
1473+
tx_crq.v1.correlator =
1474+
cpu_to_be32(index | IBMVNIC_TSO_POOL_MASK);
14821475
else
1483-
tx_crq.v1.dma_reg = cpu_to_be16(tx_pool->long_term_buff.map_id);
1476+
tx_crq.v1.correlator = cpu_to_be32(index);
1477+
tx_crq.v1.dma_reg = cpu_to_be16(tx_pool->long_term_buff.map_id);
14841478
tx_crq.v1.sge_len = cpu_to_be32(skb->len);
14851479
tx_crq.v1.ioba = cpu_to_be64(data_dma_addr);
14861480

@@ -1543,7 +1537,7 @@ static int ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
15431537

15441538
if (tx_pool->consumer_index == 0)
15451539
tx_pool->consumer_index =
1546-
adapter->req_tx_entries_per_subcrq - 1;
1540+
tx_pool->num_buffers - 1;
15471541
else
15481542
tx_pool->consumer_index--;
15491543

@@ -2547,6 +2541,7 @@ static int ibmvnic_complete_tx(struct ibmvnic_adapter *adapter,
25472541
struct ibmvnic_sub_crq_queue *scrq)
25482542
{
25492543
struct device *dev = &adapter->vdev->dev;
2544+
struct ibmvnic_tx_pool *tx_pool;
25502545
struct ibmvnic_tx_buff *txbuff;
25512546
union sub_crq *next;
25522547
int index;
@@ -2566,7 +2561,14 @@ static int ibmvnic_complete_tx(struct ibmvnic_adapter *adapter,
25662561
continue;
25672562
}
25682563
index = be32_to_cpu(next->tx_comp.correlators[i]);
2569-
txbuff = &adapter->tx_pool[pool].tx_buff[index];
2564+
if (index & IBMVNIC_TSO_POOL_MASK) {
2565+
tx_pool = &adapter->tso_pool[pool];
2566+
index &= ~IBMVNIC_TSO_POOL_MASK;
2567+
} else {
2568+
tx_pool = &adapter->tx_pool[pool];
2569+
}
2570+
2571+
txbuff = &tx_pool->tx_buff[index];
25702572

25712573
for (j = 0; j < IBMVNIC_MAX_FRAGS_PER_CRQ; j++) {
25722574
if (!txbuff->data_dma[j])
@@ -2589,11 +2591,10 @@ static int ibmvnic_complete_tx(struct ibmvnic_adapter *adapter,
25892591

25902592
num_entries += txbuff->num_entries;
25912593

2592-
adapter->tx_pool[pool].free_map[adapter->tx_pool[pool].
2593-
producer_index] = index;
2594-
adapter->tx_pool[pool].producer_index =
2595-
(adapter->tx_pool[pool].producer_index + 1) %
2596-
adapter->req_tx_entries_per_subcrq;
2594+
tx_pool->free_map[tx_pool->producer_index] = index;
2595+
tx_pool->producer_index =
2596+
(tx_pool->producer_index + 1) %
2597+
tx_pool->num_buffers;
25972598
}
25982599
/* remove tx_comp scrq*/
25992600
next->tx_comp.first = 0;

drivers/net/ethernet/ibm/ibmvnic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
#define IBMVNIC_TSO_BUF_SZ 65536
4545
#define IBMVNIC_TSO_BUFS 64
46+
#define IBMVNIC_TSO_POOL_MASK 0x80000000
4647

4748
#define IBMVNIC_MAX_LTB_SIZE ((1 << (MAX_ORDER - 1)) * PAGE_SIZE)
4849
#define IBMVNIC_BUFFER_HLEN 500

0 commit comments

Comments
 (0)