]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
net: ena: replace free_tx/rx_ids union with single free_ids field in ena_ring
authorSameeh Jubran <sameehj@amazon.com>
Mon, 3 Jun 2019 14:43:21 +0000 (17:43 +0300)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 13 Nov 2019 17:07:37 +0000 (18:07 +0100)
BugLink: https://bugs.launchpad.net/bugs/1850175
struct ena_ring holds a union of free_rx_ids and free_tx_ids.
Both of the above fields mean the exact same thing and are used
exactly the same way.
Furthermore, these fields are always used with a prefix of the
type of ring. So for tx it will be tx_ring->free_tx_ids, and for
rx it will be rx_ring->free_rx_ids, which shows how redundant the
"_tx" and "_rx" parts are.
Furthermore still, this may lead to confusing code like where
tx_ring->free_rx_ids which works correctly but looks like a mess.

This commit removes the aforementioned redundancy by replacing the
free_rx/tx_ids union with a single free_ids field.
It also changes a single goto label name from err_free_tx_ids: to
err_tx_free_ids: for consistency with the above new notation.

Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
Signed-off-by: Sameeh Jubran <sameehj@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit f917249833c7a00ea8be39b1bcb3ec8ef3aea45f)
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Khaled Elmously <khalid.elmously@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/net/ethernet/amazon/ena/ena_netdev.c
drivers/net/ethernet/amazon/ena/ena_netdev.h

index 17f7d7dcd6914a9c49ae71a405de304c3f152621..1795772f18e1e43d5fdcfbacb8595ce2e7dd159f 100644 (file)
@@ -229,11 +229,11 @@ static int ena_setup_tx_resources(struct ena_adapter *adapter, int qid)
        }
 
        size = sizeof(u16) * tx_ring->ring_size;
-       tx_ring->free_tx_ids = vzalloc_node(size, node);
-       if (!tx_ring->free_tx_ids) {
-               tx_ring->free_tx_ids = vzalloc(size);
-               if (!tx_ring->free_tx_ids)
-                       goto err_free_tx_ids;
+       tx_ring->free_ids = vzalloc_node(size, node);
+       if (!tx_ring->free_ids) {
+               tx_ring->free_ids = vzalloc(size);
+               if (!tx_ring->free_ids)
+                       goto err_tx_free_ids;
        }
 
        size = tx_ring->tx_max_header_size;
@@ -246,7 +246,7 @@ static int ena_setup_tx_resources(struct ena_adapter *adapter, int qid)
 
        /* Req id ring for TX out of order completions */
        for (i = 0; i < tx_ring->ring_size; i++)
-               tx_ring->free_tx_ids[i] = i;
+               tx_ring->free_ids[i] = i;
 
        /* Reset tx statistics */
        memset(&tx_ring->tx_stats, 0x0, sizeof(tx_ring->tx_stats));
@@ -257,9 +257,9 @@ static int ena_setup_tx_resources(struct ena_adapter *adapter, int qid)
        return 0;
 
 err_push_buf_intermediate_buf:
-       vfree(tx_ring->free_tx_ids);
-       tx_ring->free_tx_ids = NULL;
-err_free_tx_ids:
+       vfree(tx_ring->free_ids);
+       tx_ring->free_ids = NULL;
+err_tx_free_ids:
        vfree(tx_ring->tx_buffer_info);
        tx_ring->tx_buffer_info = NULL;
 err_tx_buffer_info:
@@ -279,8 +279,8 @@ static void ena_free_tx_resources(struct ena_adapter *adapter, int qid)
        vfree(tx_ring->tx_buffer_info);
        tx_ring->tx_buffer_info = NULL;
 
-       vfree(tx_ring->free_tx_ids);
-       tx_ring->free_tx_ids = NULL;
+       vfree(tx_ring->free_ids);
+       tx_ring->free_ids = NULL;
 
        vfree(tx_ring->push_buf_intermediate_buf);
        tx_ring->push_buf_intermediate_buf = NULL;
@@ -378,10 +378,10 @@ static int ena_setup_rx_resources(struct ena_adapter *adapter,
        }
 
        size = sizeof(u16) * rx_ring->ring_size;
-       rx_ring->free_rx_ids = vzalloc_node(size, node);
-       if (!rx_ring->free_rx_ids) {
-               rx_ring->free_rx_ids = vzalloc(size);
-               if (!rx_ring->free_rx_ids) {
+       rx_ring->free_ids = vzalloc_node(size, node);
+       if (!rx_ring->free_ids) {
+               rx_ring->free_ids = vzalloc(size);
+               if (!rx_ring->free_ids) {
                        vfree(rx_ring->rx_buffer_info);
                        rx_ring->rx_buffer_info = NULL;
                        return -ENOMEM;
@@ -390,7 +390,7 @@ static int ena_setup_rx_resources(struct ena_adapter *adapter,
 
        /* Req id ring for receiving RX pkts out of order */
        for (i = 0; i < rx_ring->ring_size; i++)
-               rx_ring->free_rx_ids[i] = i;
+               rx_ring->free_ids[i] = i;
 
        /* Reset rx statistics */
        memset(&rx_ring->rx_stats, 0x0, sizeof(rx_ring->rx_stats));
@@ -416,8 +416,8 @@ static void ena_free_rx_resources(struct ena_adapter *adapter,
        vfree(rx_ring->rx_buffer_info);
        rx_ring->rx_buffer_info = NULL;
 
-       vfree(rx_ring->free_rx_ids);
-       rx_ring->free_rx_ids = NULL;
+       vfree(rx_ring->free_ids);
+       rx_ring->free_ids = NULL;
 }
 
 /* ena_setup_all_rx_resources - allocate I/O Rx queues resources for all queues
@@ -532,7 +532,7 @@ static int ena_refill_rx_bufs(struct ena_ring *rx_ring, u32 num)
        for (i = 0; i < num; i++) {
                struct ena_rx_buffer *rx_info;
 
-               req_id = rx_ring->free_rx_ids[next_to_use];
+               req_id = rx_ring->free_ids[next_to_use];
                rc = validate_rx_req_id(rx_ring, req_id);
                if (unlikely(rc < 0))
                        break;
@@ -798,7 +798,7 @@ static int ena_clean_tx_irq(struct ena_ring *tx_ring, u32 budget)
                tx_pkts++;
                total_done += tx_info->tx_descs;
 
-               tx_ring->free_tx_ids[next_to_clean] = req_id;
+               tx_ring->free_ids[next_to_clean] = req_id;
                next_to_clean = ENA_TX_RING_IDX_NEXT(next_to_clean,
                                                     tx_ring->ring_size);
        }
@@ -912,7 +912,7 @@ static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring,
 
                skb_put(skb, len);
                skb->protocol = eth_type_trans(skb, rx_ring->netdev);
-               rx_ring->free_rx_ids[*next_to_clean] = req_id;
+               rx_ring->free_ids[*next_to_clean] = req_id;
                *next_to_clean = ENA_RX_RING_IDX_ADD(*next_to_clean, descs,
                                                     rx_ring->ring_size);
                return skb;
@@ -936,7 +936,7 @@ static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring,
 
                rx_info->page = NULL;
 
-               rx_ring->free_rx_ids[*next_to_clean] = req_id;
+               rx_ring->free_ids[*next_to_clean] = req_id;
                *next_to_clean =
                        ENA_RX_RING_IDX_NEXT(*next_to_clean,
                                             rx_ring->ring_size);
@@ -1089,7 +1089,7 @@ static int ena_clean_rx_irq(struct ena_ring *rx_ring, struct napi_struct *napi,
                /* exit if we failed to retrieve a buffer */
                if (unlikely(!skb)) {
                        for (i = 0; i < ena_rx_ctx.descs; i++) {
-                               rx_ring->free_tx_ids[next_to_clean] =
+                               rx_ring->free_ids[next_to_clean] =
                                        rx_ring->ena_bufs[i].req_id;
                                next_to_clean =
                                        ENA_RX_RING_IDX_NEXT(next_to_clean,
@@ -2153,7 +2153,7 @@ static netdev_tx_t ena_start_xmit(struct sk_buff *skb, struct net_device *dev)
        skb_tx_timestamp(skb);
 
        next_to_use = tx_ring->next_to_use;
-       req_id = tx_ring->free_tx_ids[next_to_use];
+       req_id = tx_ring->free_ids[next_to_use];
        tx_info = &tx_ring->tx_buffer_info[req_id];
        tx_info->num_of_bufs = 0;
 
index 0681e18b0019f3fc06dcbc43a6f129931056269b..74c316081499c2a01f933e7a85cdfe298007839c 100644 (file)
@@ -221,13 +221,10 @@ struct ena_stats_rx {
 };
 
 struct ena_ring {
-       union {
-               /* Holds the empty requests for TX/RX
-                * out of order completions
-                */
-               u16 *free_tx_ids;
-               u16 *free_rx_ids;
-       };
+       /* Holds the empty requests for TX/RX
+        * out of order completions
+        */
+       u16 *free_ids;
 
        union {
                struct ena_tx_buffer *tx_buffer_info;