Skip to content

Commit

Permalink
ibmvnic: store RX and TX subCRQ handle array in ibmvnic_adapter struct
Browse files Browse the repository at this point in the history
Currently the driver reads RX and TX subCRQ handle array directly from
a DMA-mapped buffer address when it needs to make a H_SEND_SUBCRQ
hcall. This patch stores that information in the ibmvnic_sub_crq_queue
structure instead of reading from the buffer received at login. The
overall goal of this patch is to parse relevant information from the
login response buffer and store it in the driver's private data
structures so that we don't need to read directly from the buffer and
can then free up that memory.

Signed-off-by: Cristobal Forno <[email protected]>
Reviewed-by: Jesse Brandeburg <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
cforno12-zz authored and davem330 committed Aug 19, 2020
1 parent 0b3fc8b commit f3ae59c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
38 changes: 26 additions & 12 deletions drivers/net/ethernet/ibm/ibmvnic.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ static void replenish_rx_pool(struct ibmvnic_adapter *adapter,
struct ibmvnic_rx_pool *pool)
{
int count = pool->size - atomic_read(&pool->available);
u64 handle = adapter->rx_scrq[pool->index]->handle;
struct device *dev = &adapter->vdev->dev;
int buffers_added = 0;
unsigned long lpar_rc;
Expand All @@ -314,18 +315,13 @@ static void replenish_rx_pool(struct ibmvnic_adapter *adapter,
unsigned int offset;
dma_addr_t dma_addr;
unsigned char *dst;
u64 *handle_array;
int shift = 0;
int index;
int i;

if (!pool->active)
return;

handle_array = (u64 *)((u8 *)(adapter->login_rsp_buf) +
be32_to_cpu(adapter->login_rsp_buf->
off_rxadd_subcrqs));

for (i = 0; i < count; ++i) {
skb = alloc_skb(pool->buff_size, GFP_ATOMIC);
if (!skb) {
Expand Down Expand Up @@ -369,8 +365,7 @@ static void replenish_rx_pool(struct ibmvnic_adapter *adapter,
#endif
sub_crq.rx_add.len = cpu_to_be32(pool->buff_size << shift);

lpar_rc = send_subcrq(adapter, handle_array[pool->index],
&sub_crq);
lpar_rc = send_subcrq(adapter, handle, &sub_crq);
if (lpar_rc != H_SUCCESS)
goto failure;

Expand Down Expand Up @@ -1524,9 +1519,9 @@ static netdev_tx_t ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
unsigned int offset;
int num_entries = 1;
unsigned char *dst;
u64 *handle_array;
int index = 0;
u8 proto = 0;
u64 handle;
netdev_tx_t ret = NETDEV_TX_OK;

if (test_bit(0, &adapter->resetting)) {
Expand All @@ -1553,8 +1548,7 @@ static netdev_tx_t ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)

tx_scrq = adapter->tx_scrq[queue_num];
txq = netdev_get_tx_queue(netdev, skb_get_queue_mapping(skb));
handle_array = (u64 *)((u8 *)(adapter->login_rsp_buf) +
be32_to_cpu(adapter->login_rsp_buf->off_txsubm_subcrqs));
handle = tx_scrq->handle;

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

Expand Down Expand Up @@ -1666,14 +1660,14 @@ static netdev_tx_t ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
ret = NETDEV_TX_OK;
goto tx_err_out;
}
lpar_rc = send_subcrq_indirect(adapter, handle_array[queue_num],
lpar_rc = send_subcrq_indirect(adapter, handle,
(u64)tx_buff->indir_dma,
(u64)num_entries);
dma_unmap_single(dev, tx_buff->indir_dma,
sizeof(tx_buff->indir_arr), DMA_TO_DEVICE);
} else {
tx_buff->num_entries = num_entries;
lpar_rc = send_subcrq(adapter, handle_array[queue_num],
lpar_rc = send_subcrq(adapter, handle,
&tx_crq);
}
if (lpar_rc != H_SUCCESS) {
Expand Down Expand Up @@ -4292,6 +4286,10 @@ static int handle_login_rsp(union ibmvnic_crq *login_rsp_crq,
struct net_device *netdev = adapter->netdev;
struct ibmvnic_login_rsp_buffer *login_rsp = adapter->login_rsp_buf;
struct ibmvnic_login_buffer *login = adapter->login_buf;
u64 *tx_handle_array;
u64 *rx_handle_array;
int num_tx_pools;
int num_rx_pools;
int i;

dma_unmap_single(dev, adapter->login_buf_token, adapter->login_buf_sz,
Expand Down Expand Up @@ -4326,6 +4324,22 @@ static int handle_login_rsp(union ibmvnic_crq *login_rsp_crq,
ibmvnic_remove(adapter->vdev);
return -EIO;
}

num_tx_pools = be32_to_cpu(adapter->login_rsp_buf->num_txsubm_subcrqs);
num_rx_pools = be32_to_cpu(adapter->login_rsp_buf->num_rxadd_subcrqs);

tx_handle_array = (u64 *)((u8 *)(adapter->login_rsp_buf) +
be32_to_cpu(adapter->login_rsp_buf->off_txsubm_subcrqs));
rx_handle_array = (u64 *)((u8 *)(adapter->login_rsp_buf) +
be32_to_cpu(adapter->login_rsp_buf->off_rxadd_subcrqs));

for (i = 0; i < num_tx_pools; i++)
adapter->tx_scrq[i]->handle = tx_handle_array[i];

for (i = 0; i < num_rx_pools; i++)
adapter->rx_scrq[i]->handle = rx_handle_array[i];

release_login_rsp_buffer(adapter);
release_login_buffer(adapter);
complete(&adapter->init_done);

Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/ibm/ibmvnic.h
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,7 @@ struct ibmvnic_sub_crq_queue {
struct ibmvnic_adapter *adapter;
atomic_t used;
char name[32];
u64 handle;
};

struct ibmvnic_long_term_buff {
Expand Down

0 comments on commit f3ae59c

Please sign in to comment.