Thread (4 messages) 4 messages, 2 authors, 2017-02-09

[PATCH net-next 1/2] net/devlink: Add E-Switch encapsulation control

flat view
STALE3528d REVIEWED: 1 (0M)

From: Or Gerlitz <hidden>
Date: 2017-02-09 16:24:32
Subsystem: devlink, networking [general], the rest · Maintainers: Jiri Pirko, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

1 review trailer.

From: Roi Dayan <redacted>

This is an e-switch global knob to enable/disable HW support for applying
encapsulation/decapsulation to VF traffic as part of SRIOV e-switch offloading.

The actual encap/decap is carried out (along with the matching and other actions)
per offloaded e-switch rules, e.g as done when offloading the TC tunnel key action.

The supported mode are enable/disable.

Signed-off-by: Roi Dayan <redacted>
Reviewed-by: Or Gerlitz <redacted>
---
 include/net/devlink.h        |  2 ++
 include/uapi/linux/devlink.h |  1 +
 net/core/devlink.c           | 22 ++++++++++++++++++++++
 3 files changed, 25 insertions(+)
diff --git a/include/net/devlink.h b/include/net/devlink.h
index d29e5fc..a09bff4 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -94,6 +94,8 @@ struct devlink_ops {
 	int (*eswitch_mode_set)(struct devlink *devlink, u16 mode);
 	int (*eswitch_inline_mode_get)(struct devlink *devlink, u8 *p_inline_mode);
 	int (*eswitch_inline_mode_set)(struct devlink *devlink, u8 inline_mode);
+	int (*eswitch_encap_get)(struct devlink *devlink, bool *p_encap);
+	int (*eswitch_encap_set)(struct devlink *devlink, bool encap);
 };
 
 static inline void *devlink_priv(struct devlink *devlink)
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index 0f1f3a1..c3f05c6 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -147,6 +147,7 @@ enum devlink_attr {
 	DEVLINK_ATTR_SB_OCC_MAX,		/* u32 */
 	DEVLINK_ATTR_ESWITCH_MODE,		/* u16 */
 	DEVLINK_ATTR_ESWITCH_INLINE_MODE,	/* u8 */
+	DEVLINK_ATTR_ESWITCH_ENCAP,		/* u8 */
 
 	/* add new attributes above here, update the policy in devlink.c */
 
diff --git a/net/core/devlink.c b/net/core/devlink.c
index e9c1e6a..9af5372 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -1401,6 +1401,7 @@ static int devlink_nl_eswitch_fill(struct sk_buff *msg, struct devlink *devlink,
 	int err = 0;
 	u16 mode;
 	u8 inline_mode;
+	bool encap;
 
 	hdr = genlmsg_put(msg, portid, seq, &devlink_nl_family, flags, cmd);
 	if (!hdr)
@@ -1429,6 +1430,15 @@ static int devlink_nl_eswitch_fill(struct sk_buff *msg, struct devlink *devlink,
 			goto nla_put_failure;
 	}
 
+	if (mode == DEVLINK_ESWITCH_MODE_SWITCHDEV && ops->eswitch_encap_get) {
+		err = ops->eswitch_encap_get(devlink, &encap);
+		if (err)
+			goto nla_put_failure;
+		err = nla_put_u8(msg, DEVLINK_ATTR_ESWITCH_ENCAP, encap);
+		if (err)
+			goto nla_put_failure;
+	}
+
 	genlmsg_end(msg, hdr);
 	return 0;
 
@@ -1470,11 +1480,23 @@ static int devlink_nl_cmd_eswitch_set_doit(struct sk_buff *skb,
 	const struct devlink_ops *ops = devlink->ops;
 	u16 mode;
 	u8 inline_mode;
+	bool encap;
 	int err = 0;
 
 	if (!ops)
 		return -EOPNOTSUPP;
 
+	if (info->attrs[DEVLINK_ATTR_ESWITCH_ENCAP]) {
+		if (!ops->eswitch_encap_set)
+			return -EOPNOTSUPP;
+		if (!info->attrs[DEVLINK_ATTR_ESWITCH_MODE])
+			return -EINVAL;
+		encap = nla_get_u8(info->attrs[DEVLINK_ATTR_ESWITCH_ENCAP]);
+		err = ops->eswitch_encap_set(devlink, encap);
+		if (err)
+			return err;
+	}
+
 	if (info->attrs[DEVLINK_ATTR_ESWITCH_MODE]) {
 		if (!ops->eswitch_mode_set)
 			return -EOPNOTSUPP;
-- 
2.5.5
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help