[ovs-dev] [PATCH 4/7] netdev-dpdk: Refactor netdev_dpdk structure.

Bhanuprakash Bodireddy bhanuprakash.bodireddy at intel.com
Sun Oct 1 07:57:37 UTC 2017


This commit introduces below changes to netdev_dpdk structure.

- Mark cachelines and reorder few member variables.
- Maintain the grouping of related member variables.
- Add comment on the information on pad bytes where ever appropriate, so
  new members can be introduced in the future to fill the gaps.

  Below is how this structure looks with this commit.

                  Member                    size

         OVS_CACHE_LINE_MARKER cacheline0;
             dpdk_port_t port_id;            1
             bool attached;                  1
             ...

         OVS_CACHE_LINE_MARKER cacheline1;
             struct ovs_mutex;              48
             struct dpdk_mp *dpdk_mp;        8
             ...

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy at intel.com>
---
 lib/netdev-dpdk.c | 158 +++++++++++++++++++++++++++++-------------------------
 1 file changed, 84 insertions(+), 74 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index c60f46f..d999807 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -350,80 +350,90 @@ enum dpdk_hw_ol_features {
 };
 
 struct netdev_dpdk {
-    struct netdev up;
-    dpdk_port_t port_id;
-    int max_packet_len;
-    enum dpdk_dev_type type;
-
-    struct dpdk_tx_queue *tx_q;
-
-    struct ovs_mutex mutex OVS_ACQ_AFTER(dpdk_mutex);
-
-    struct dpdk_mp *dpdk_mp;
-    int mtu;
-    int socket_id;
-    int buf_size;
-    struct netdev_stats stats;
-    /* Protects stats */
-    rte_spinlock_t stats_lock;
-
-    struct eth_addr hwaddr;
-    enum netdev_flags flags;
-
-    struct rte_eth_link link;
-    int link_reset_cnt;
-
-    /* virtio identifier for vhost devices */
-    ovsrcu_index vid;
-
-    /* True if vHost device is 'up' and has been reconfigured at least once */
-    bool vhost_reconfigured;
-
-    /* Identifier used to distinguish vhost devices from each other. */
-    char vhost_id[PATH_MAX];
-
-    /* Device arguments for dpdk ports */
-    char *devargs;
-
-    /* If true, device was attached by rte_eth_dev_attach(). */
-    bool attached;
-
-    /* In dpdk_list. */
-    struct ovs_list list_node OVS_GUARDED_BY(dpdk_mutex);
-
-    /* QoS configuration and lock for the device */
-    OVSRCU_TYPE(struct qos_conf *) qos_conf;
-
-    /* The following properties cannot be changed when a device is running,
-     * so we remember the request and update them next time
-     * netdev_dpdk*_reconfigure() is called */
-    int requested_mtu;
-    int requested_n_txq;
-    int requested_n_rxq;
-    int requested_rxq_size;
-    int requested_txq_size;
-
-    /* Number of rx/tx descriptors for physical devices */
-    int rxq_size;
-    int txq_size;
-
-    /* Socket ID detected when vHost device is brought up */
-    int requested_socket_id;
-
-    /* Denotes whether vHost port is client/server mode */
-    uint64_t vhost_driver_flags;
-
-    /* Ingress Policer */
-    OVSRCU_TYPE(struct ingress_policer *) ingress_policer;
-    uint32_t policer_rate;
-    uint32_t policer_burst;
-
-    /* DPDK-ETH Flow control */
-    struct rte_eth_fc_conf fc_conf;
-
-    /* DPDK-ETH hardware offload features,
-     * from the enum set 'dpdk_hw_ol_features' */
-    uint32_t hw_ol_features;
+    PADDED_MEMBERS_CACHELINE_MARKER(CACHE_LINE_SIZE, cacheline0,
+        dpdk_port_t port_id;
+
+        /* If true, device was attached by rte_eth_dev_attach(). */
+        bool attached;
+        struct eth_addr hwaddr;
+        int mtu;
+        int socket_id;
+        int buf_size;
+        int max_packet_len;
+        enum dpdk_dev_type type;
+        enum netdev_flags flags;
+        char *devargs;  /* Device arguments for dpdk ports */
+        struct dpdk_tx_queue *tx_q;
+        struct rte_eth_link link;
+        int link_reset_cnt;
+        /* 4 pad bytes here. */
+    );
+
+    PADDED_MEMBERS_CACHELINE_MARKER(CACHE_LINE_SIZE, cacheline1,
+        struct ovs_mutex mutex OVS_ACQ_AFTER(dpdk_mutex);
+        struct dpdk_mp *dpdk_mp;
+
+        /* virtio identifier for vhost devices */
+        ovsrcu_index vid;
+
+        /* True if vHost device is 'up' and has been reconfigured at least once */
+        bool vhost_reconfigured;
+        /* 3 pad bytes here. */
+    );
+
+    PADDED_MEMBERS(CACHE_LINE_SIZE,
+        /* Identifier used to distinguish vhost devices from each other. */
+        char vhost_id[PATH_MAX];
+    );
+
+    PADDED_MEMBERS(CACHE_LINE_SIZE,
+        struct netdev up;
+        /* In dpdk_list. */
+        struct ovs_list list_node OVS_GUARDED_BY(dpdk_mutex);
+
+        /* QoS configuration and lock for the device */
+        OVSRCU_TYPE(struct qos_conf *) qos_conf;
+
+        /* Ingress Policer */
+        OVSRCU_TYPE(struct ingress_policer *) ingress_policer;
+        uint32_t policer_rate;
+        uint32_t policer_burst;
+    );
+
+    PADDED_MEMBERS(CACHE_LINE_SIZE,
+        struct netdev_stats stats;
+        /* Protects stats */
+        rte_spinlock_t stats_lock;
+        /* 44 pad bytes here. */
+    );
+
+    PADDED_MEMBERS(CACHE_LINE_SIZE,
+        /* The following properties cannot be changed when a device is running,
+         * so we remember the request and update them next time
+         * netdev_dpdk*_reconfigure() is called */
+        int requested_mtu;
+        int requested_n_txq;
+        int requested_n_rxq;
+        int requested_rxq_size;
+        int requested_txq_size;
+
+        /* Number of rx/tx descriptors for physical devices */
+        int rxq_size;
+        int txq_size;
+
+        /* Socket ID detected when vHost device is brought up */
+        int requested_socket_id;
+
+        /* Denotes whether vHost port is client/server mode */
+        uint64_t vhost_driver_flags;
+
+        /* DPDK-ETH Flow control */
+        struct rte_eth_fc_conf fc_conf;
+
+        /* DPDK-ETH hardware offload features,
+         * from the enum set 'dpdk_hw_ol_features' */
+        uint32_t hw_ol_features;
+    );
 };
 
 struct netdev_rxq_dpdk {
-- 
2.4.11



More information about the dev mailing list