Skip to content
This repository has been archived by the owner on Nov 21, 2022. It is now read-only.

Commit

Permalink
ibmvnic: Use common counter for capabilities checks
Browse files Browse the repository at this point in the history
Two different counters were being used for capabilities
requests and queries. These commands are not called
at the same time so there is no reason a single counter
cannot be used.

Signed-off-by: Thomas Falcon <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
tlfalcon authored and davem330 committed Feb 19, 2017
1 parent 6c267b3 commit 901e040
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 35 deletions.
71 changes: 38 additions & 33 deletions drivers/net/ethernet/ibm/ibmvnic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1260,8 +1260,6 @@ static void release_sub_crqs(struct ibmvnic_adapter *adapter)
}
adapter->rx_scrq = NULL;
}

adapter->requested_caps = 0;
}

static void release_sub_crqs_no_irqs(struct ibmvnic_adapter *adapter)
Expand All @@ -1283,8 +1281,6 @@ static void release_sub_crqs_no_irqs(struct ibmvnic_adapter *adapter)
adapter->rx_scrq[i]);
adapter->rx_scrq = NULL;
}

adapter->requested_caps = 0;
}

static int disable_scrq_irq(struct ibmvnic_adapter *adapter,
Expand Down Expand Up @@ -1572,43 +1568,51 @@ static void init_sub_crqs(struct ibmvnic_adapter *adapter, int retry)

crq.request_capability.capability = cpu_to_be16(REQ_TX_QUEUES);
crq.request_capability.number = cpu_to_be64(adapter->req_tx_queues);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.request_capability.capability = cpu_to_be16(REQ_RX_QUEUES);
crq.request_capability.number = cpu_to_be64(adapter->req_rx_queues);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.request_capability.capability = cpu_to_be16(REQ_RX_ADD_QUEUES);
crq.request_capability.number = cpu_to_be64(adapter->req_rx_add_queues);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.request_capability.capability =
cpu_to_be16(REQ_TX_ENTRIES_PER_SUBCRQ);
crq.request_capability.number =
cpu_to_be64(adapter->req_tx_entries_per_subcrq);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.request_capability.capability =
cpu_to_be16(REQ_RX_ADD_ENTRIES_PER_SUBCRQ);
crq.request_capability.number =
cpu_to_be64(adapter->req_rx_add_entries_per_subcrq);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.request_capability.capability = cpu_to_be16(REQ_MTU);
crq.request_capability.number = cpu_to_be64(adapter->req_mtu);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

if (adapter->netdev->flags & IFF_PROMISC) {
if (adapter->promisc_supported) {
crq.request_capability.capability =
cpu_to_be16(PROMISC_REQUESTED);
crq.request_capability.number = cpu_to_be64(1);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);
}
} else {
crq.request_capability.capability =
cpu_to_be16(PROMISC_REQUESTED);
crq.request_capability.number = cpu_to_be64(0);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);
}

Expand Down Expand Up @@ -1960,112 +1964,112 @@ static void send_cap_queries(struct ibmvnic_adapter *adapter)
{
union ibmvnic_crq crq;

atomic_set(&adapter->running_cap_queries, 0);
atomic_set(&adapter->running_cap_crqs, 0);
memset(&crq, 0, sizeof(crq));
crq.query_capability.first = IBMVNIC_CRQ_CMD;
crq.query_capability.cmd = QUERY_CAPABILITY;

crq.query_capability.capability = cpu_to_be16(MIN_TX_QUEUES);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.query_capability.capability = cpu_to_be16(MIN_RX_QUEUES);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.query_capability.capability = cpu_to_be16(MIN_RX_ADD_QUEUES);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.query_capability.capability = cpu_to_be16(MAX_TX_QUEUES);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.query_capability.capability = cpu_to_be16(MAX_RX_QUEUES);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.query_capability.capability = cpu_to_be16(MAX_RX_ADD_QUEUES);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.query_capability.capability =
cpu_to_be16(MIN_TX_ENTRIES_PER_SUBCRQ);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.query_capability.capability =
cpu_to_be16(MIN_RX_ADD_ENTRIES_PER_SUBCRQ);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.query_capability.capability =
cpu_to_be16(MAX_TX_ENTRIES_PER_SUBCRQ);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.query_capability.capability =
cpu_to_be16(MAX_RX_ADD_ENTRIES_PER_SUBCRQ);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.query_capability.capability = cpu_to_be16(TCP_IP_OFFLOAD);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.query_capability.capability = cpu_to_be16(PROMISC_SUPPORTED);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.query_capability.capability = cpu_to_be16(MIN_MTU);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.query_capability.capability = cpu_to_be16(MAX_MTU);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.query_capability.capability = cpu_to_be16(MAX_MULTICAST_FILTERS);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.query_capability.capability = cpu_to_be16(VLAN_HEADER_INSERTION);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.query_capability.capability = cpu_to_be16(MAX_TX_SG_ENTRIES);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.query_capability.capability = cpu_to_be16(RX_SG_SUPPORTED);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.query_capability.capability = cpu_to_be16(OPT_TX_COMP_SUB_QUEUES);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.query_capability.capability = cpu_to_be16(OPT_RX_COMP_QUEUES);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.query_capability.capability =
cpu_to_be16(OPT_RX_BUFADD_Q_PER_RX_COMP_Q);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.query_capability.capability =
cpu_to_be16(OPT_TX_ENTRIES_PER_SUBCRQ);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.query_capability.capability =
cpu_to_be16(OPT_RXBA_ENTRIES_PER_SUBCRQ);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);

crq.query_capability.capability = cpu_to_be16(TX_RX_DESC_REQ);
atomic_inc(&adapter->running_cap_queries);
atomic_inc(&adapter->running_cap_crqs);
ibmvnic_send_crq(adapter, &crq);
}

Expand Down Expand Up @@ -2353,6 +2357,7 @@ static void handle_request_cap_rsp(union ibmvnic_crq *crq,
u64 *req_value;
char *name;

atomic_dec(&adapter->running_cap_crqs);
switch (be16_to_cpu(crq->request_capability_rsp.capability)) {
case REQ_TX_QUEUES:
req_value = &adapter->req_tx_queues;
Expand Down Expand Up @@ -2407,7 +2412,7 @@ static void handle_request_cap_rsp(union ibmvnic_crq *crq,
}

/* Done receiving requested capabilities, query IP offload support */
if (++adapter->requested_caps == 7) {
if (atomic_read(&adapter->running_cap_crqs) == 0) {
union ibmvnic_crq newcrq;
int buf_sz = sizeof(struct ibmvnic_query_ip_offload_buffer);
struct ibmvnic_query_ip_offload_buffer *ip_offload_buf =
Expand Down Expand Up @@ -2548,9 +2553,9 @@ static void handle_query_cap_rsp(union ibmvnic_crq *crq,
struct device *dev = &adapter->vdev->dev;
long rc;

atomic_dec(&adapter->running_cap_queries);
atomic_dec(&adapter->running_cap_crqs);
netdev_dbg(netdev, "Outstanding queries: %d\n",
atomic_read(&adapter->running_cap_queries));
atomic_read(&adapter->running_cap_crqs));
rc = crq->query_capability.rc.code;
if (rc) {
dev_err(dev, "Error %ld in QUERY_CAP_RSP\n", rc);
Expand Down Expand Up @@ -2708,7 +2713,7 @@ static void handle_query_cap_rsp(union ibmvnic_crq *crq,
}

out:
if (atomic_read(&adapter->running_cap_queries) == 0)
if (atomic_read(&adapter->running_cap_crqs) == 0)
init_sub_crqs(adapter, 0);
/* We're done querying the capabilities, initialize sub-crqs */
}
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/ethernet/ibm/ibmvnic.h
Original file line number Diff line number Diff line change
Expand Up @@ -976,11 +976,10 @@ struct ibmvnic_adapter {
dma_addr_t login_rsp_buf_token;
int login_rsp_buf_sz;

atomic_t running_cap_queries;
atomic_t running_cap_crqs;

struct ibmvnic_sub_crq_queue **tx_scrq;
struct ibmvnic_sub_crq_queue **rx_scrq;
int requested_caps;
bool renegotiate;

/* rx structs */
Expand Down

0 comments on commit 901e040

Please sign in to comment.