diff mbox series

[ovs-dev,03/62] netdev: Allow storing dpif type into netdev structure

Message ID 20201228092520.11807-4-taoyunxiang@cmss.chinamobile.com
State Not Applicable
Headers show
Series DPDK Offload API to test | expand

Commit Message

Tao YunXiang Dec. 28, 2020, 9:24 a.m. UTC
From: Liuchang <liuchang@cmss.chinamobile.com>

Code Source From: Self Code

Description:

    Storing of the dpif type of the owning datapath interface will allow
us to easily distinguish, for example, userspace tunneling ports from
the system ones.  This is required in terms of HW offloading to avoid
offloading of userspace flows to kernel interfaces that doesn't belong
to userspace datapath, but have same dpif_port names.

Jira:  #[Optional]
市场项目编号(名称):[Optional
---
 lib/netdev-provider.h |  3 ++-
 lib/netdev.c          | 16 ++++++++++++++++
 lib/netdev.h          |  2 ++
 3 files changed, 20 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/netdev-provider.h b/lib/netdev-provider.h
index 6f50942..1ff468b 100644
--- a/lib/netdev-provider.h
+++ b/lib/netdev-provider.h
@@ -96,7 +96,8 @@  struct netdev {
 
     /* Functions to control flow offloading. */
     OVSRCU_TYPE(const struct netdev_flow_api *) flow_api;
-    struct netdev_hw_info hw_info;	/* offload-capable netdev info */
+    const char *dpif_type;          /* Type of dpif this netdev belongs to. */
+    struct netdev_hw_info hw_info;  /* Offload-capable netdev info. */
 };
 
 static inline void
diff --git a/lib/netdev.c b/lib/netdev.c
index 8c44eee..e2d743f 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -1983,6 +1983,22 @@  netdev_get_class(const struct netdev *netdev)
     return netdev->netdev_class;
 }
 
+/* Set the type of 'dpif' this 'netdev' belongs to. */
+void
+netdev_set_dpif_type(struct netdev *netdev, const char *type)
+{
+    netdev->dpif_type = type;
+}
+
+/* Returns the type of 'dpif' this 'netdev' belongs to.
+ *
+ * The caller must not free the returned value. */
+const char *
+netdev_get_dpif_type(const struct netdev *netdev)
+{
+    return netdev->dpif_type;
+}
+
 /* Returns the netdev with 'name' or NULL if there is none.
  *
  * The caller must free the returned netdev with netdev_close(). */
diff --git a/lib/netdev.h b/lib/netdev.h
index fdbe0e1..fb50730 100644
--- a/lib/netdev.h
+++ b/lib/netdev.h
@@ -179,6 +179,8 @@  bool netdev_mtu_is_user_config(struct netdev *);
 int netdev_get_ifindex(const struct netdev *);
 int netdev_set_tx_multiq(struct netdev *, unsigned int n_txq);
 enum netdev_pt_mode netdev_get_pt_mode(const struct netdev *);
+void netdev_set_dpif_type(struct netdev *, const char *);
+const char *netdev_get_dpif_type(const struct netdev *);
 
 /* Packet reception. */
 int netdev_rxq_open(struct netdev *, struct netdev_rxq **, int id);