* [PATCH iproute2 0/2] Adding help and inline mode control to eswitch
@ 2016-11-27 11:21 Roi Dayan
2016-11-27 11:21 ` [PATCH iproute2 1/2] devlink: Add usage help for eswitch subcommand Roi Dayan
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Roi Dayan @ 2016-11-27 11:21 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, Or Gerlitz, Roi Dayan
Hi,
The first patch is adding missing help message for eswitch.
The second patch is adding functionality to show/modify eswitch inline mode.
Thanks,
Roi
Roi Dayan (2):
devlink: Add usage help for eswitch subcommand
devlink: Add option to set and show eswitch inline mode
devlink/devlink.c | 89 +++++++++++++++++++++++++++++++++++++++++++++-
include/linux/devlink.h | 8 ++++
man/man8/devlink-dev.8 | 21 ++++++++++-
3 files changed, 115 insertions(+), 3 deletions(-)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH iproute2 1/2] devlink: Add usage help for eswitch subcommand
2016-11-27 11:21 [PATCH iproute2 0/2] Adding help and inline mode control to eswitch Roi Dayan
@ 2016-11-27 11:21 ` Roi Dayan
2016-11-30 3:19 ` Stephen Hemminger
2016-11-27 11:21 ` [PATCH iproute2 2/2] devlink: Add option to set and show eswitch inline mode Roi Dayan
2016-11-27 11:30 ` [PATCH iproute2 0/2] Adding help and inline mode control to eswitch Roi Dayan
2 siblings, 1 reply; 5+ messages in thread
From: Roi Dayan @ 2016-11-27 11:21 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, Or Gerlitz, Roi Dayan
Add missing usage help for devlink dev eswitch subcommand.
Signed-off-by: Roi Dayan <roid@mellanox.com>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
---
devlink/devlink.c | 7 ++++++-
man/man8/devlink-dev.8 | 2 +-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index ccca0fb..673234f 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -963,6 +963,8 @@ static bool dl_dump_filter(struct dl *dl, struct nlattr **tb)
static void cmd_dev_help(void)
{
pr_err("Usage: devlink dev show [ DEV ]\n");
+ pr_err(" devlink dev eswitch set DEV [ mode { legacy | switchdev } ]\n");
+ pr_err(" devlink dev eswitch show DEV\n");
}
static bool cmp_arr_last_handle(struct dl *dl, const char *bus_name,
@@ -1259,7 +1261,10 @@ static int cmd_dev_eswitch_set(struct dl *dl)
static int cmd_dev_eswitch(struct dl *dl)
{
- if (dl_argv_match(dl, "set")) {
+ if (dl_argv_match(dl, "help") || dl_no_arg(dl)) {
+ cmd_dev_help();
+ return 0;
+ } else if (dl_argv_match(dl, "set")) {
dl_arg_inc(dl);
return cmd_dev_eswitch_set(dl);
} else if (dl_argv_match(dl, "show")) {
diff --git a/man/man8/devlink-dev.8 b/man/man8/devlink-dev.8
index 9ce3193..931e334 100644
--- a/man/man8/devlink-dev.8
+++ b/man/man8/devlink-dev.8
@@ -54,7 +54,7 @@ BUS_NAME/BUS_ADDRESS
.TP
.BR mode " { " legacy " | " switchdev " } "
-set eswitch mode
+Set eswitch mode
.I legacy
- Legacy SRIOV
--
1.7.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH iproute2 2/2] devlink: Add option to set and show eswitch inline mode
2016-11-27 11:21 [PATCH iproute2 0/2] Adding help and inline mode control to eswitch Roi Dayan
2016-11-27 11:21 ` [PATCH iproute2 1/2] devlink: Add usage help for eswitch subcommand Roi Dayan
@ 2016-11-27 11:21 ` Roi Dayan
2016-11-27 11:30 ` [PATCH iproute2 0/2] Adding help and inline mode control to eswitch Roi Dayan
2 siblings, 0 replies; 5+ messages in thread
From: Roi Dayan @ 2016-11-27 11:21 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, Or Gerlitz, Roi Dayan
This is needed for some HWs to do proper macthing and steering.
Possible values are none, link, network, transport.
Signed-off-by: Roi Dayan <roid@mellanox.com>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
---
devlink/devlink.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++-
include/linux/devlink.h | 8 ++++
man/man8/devlink-dev.8 | 19 +++++++++++
3 files changed, 108 insertions(+), 1 deletions(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index 673234f..23db9e7 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -28,6 +28,10 @@
#define ESWITCH_MODE_LEGACY "legacy"
#define ESWITCH_MODE_SWITCHDEV "switchdev"
+#define ESWITCH_INLINE_MODE_NONE "none"
+#define ESWITCH_INLINE_MODE_LINK "link"
+#define ESWITCH_INLINE_MODE_NETWORK "network"
+#define ESWITCH_INLINE_MODE_TRANSPORT "transport"
#define pr_err(args...) fprintf(stderr, ##args)
#define pr_out(args...) fprintf(stdout, ##args)
@@ -132,6 +136,7 @@ static void ifname_map_free(struct ifname_map *ifname_map)
#define DL_OPT_SB_TH BIT(9)
#define DL_OPT_SB_TC BIT(10)
#define DL_OPT_ESWITCH_MODE BIT(11)
+#define DL_OPT_ESWITCH_INLINE_MODE BIT(12)
struct dl_opts {
uint32_t present; /* flags of present items */
@@ -148,6 +153,7 @@ struct dl_opts {
uint32_t sb_threshold;
uint16_t sb_tc_index;
enum devlink_eswitch_mode eswitch_mode;
+ enum devlink_eswitch_inline_mode eswitch_inline_mode;
};
struct dl {
@@ -305,6 +311,9 @@ static int attr_cb(const struct nlattr *attr, void *data)
if (type == DEVLINK_ATTR_ESWITCH_MODE &&
mnl_attr_validate(attr, MNL_TYPE_U16) < 0)
return MNL_CB_ERROR;
+ if (type == DEVLINK_ATTR_ESWITCH_INLINE_MODE &&
+ mnl_attr_validate(attr, MNL_TYPE_U8) < 0)
+ return MNL_CB_ERROR;
tb[type] = attr;
return MNL_CB_OK;
}
@@ -682,6 +691,24 @@ static int eswitch_mode_get(const char *typestr,
return 0;
}
+static int eswitch_inline_mode_get(const char *typestr,
+ enum devlink_eswitch_inline_mode *p_mode)
+{
+ if (strcmp(typestr, ESWITCH_INLINE_MODE_NONE) == 0) {
+ *p_mode = DEVLINK_ESWITCH_INLINE_MODE_NONE;
+ } else if (strcmp(typestr, ESWITCH_INLINE_MODE_LINK) == 0) {
+ *p_mode = DEVLINK_ESWITCH_INLINE_MODE_LINK;
+ } else if (strcmp(typestr, ESWITCH_INLINE_MODE_NETWORK) == 0) {
+ *p_mode = DEVLINK_ESWITCH_INLINE_MODE_NETWORK;
+ } else if (strcmp(typestr, ESWITCH_INLINE_MODE_TRANSPORT) == 0) {
+ *p_mode = DEVLINK_ESWITCH_INLINE_MODE_TRANSPORT;
+ } else {
+ pr_err("Unknown eswitch inline mode \"%s\"\n", typestr);
+ return -EINVAL;
+ }
+ return 0;
+}
+
static int dl_argv_parse(struct dl *dl, uint32_t o_required,
uint32_t o_optional)
{
@@ -803,6 +830,19 @@ static int dl_argv_parse(struct dl *dl, uint32_t o_required,
if (err)
return err;
o_found |= DL_OPT_ESWITCH_MODE;
+ } else if (dl_argv_match(dl, "inline-mode") &&
+ (o_all & DL_OPT_ESWITCH_INLINE_MODE)) {
+ const char *typestr;
+
+ dl_arg_inc(dl);
+ err = dl_argv_str(dl, &typestr);
+ if (err)
+ return err;
+ err = eswitch_inline_mode_get(
+ typestr, &opts->eswitch_inline_mode);
+ if (err)
+ return err;
+ o_found |= DL_OPT_ESWITCH_INLINE_MODE;
} else {
pr_err("Unknown option \"%s\"\n", dl_argv(dl));
return -EINVAL;
@@ -863,6 +903,12 @@ static int dl_argv_parse(struct dl *dl, uint32_t o_required,
return -EINVAL;
}
+ if ((o_required & DL_OPT_ESWITCH_INLINE_MODE) &&
+ !(o_found & DL_OPT_ESWITCH_INLINE_MODE)) {
+ pr_err("E-Switch inline-mode option expected.\n");
+ return -EINVAL;
+ }
+
return 0;
}
@@ -909,6 +955,9 @@ static void dl_opts_put(struct nlmsghdr *nlh, struct dl *dl)
if (opts->present & DL_OPT_ESWITCH_MODE)
mnl_attr_put_u16(nlh, DEVLINK_ATTR_ESWITCH_MODE,
opts->eswitch_mode);
+ if (opts->present & DL_OPT_ESWITCH_INLINE_MODE)
+ mnl_attr_put_u8(nlh, DEVLINK_ATTR_ESWITCH_INLINE_MODE,
+ opts->eswitch_inline_mode);
}
static int dl_argv_parse_put(struct nlmsghdr *nlh, struct dl *dl,
@@ -964,6 +1013,7 @@ static void cmd_dev_help(void)
{
pr_err("Usage: devlink dev show [ DEV ]\n");
pr_err(" devlink dev eswitch set DEV [ mode { legacy | switchdev } ]\n");
+ pr_err(" [ inline-mode { none | link | network | transport } ]\n");
pr_err(" devlink dev eswitch show DEV\n");
}
@@ -1203,6 +1253,22 @@ static const char *eswitch_mode_name(uint32_t mode)
}
}
+static const char *eswitch_inline_mode_name(uint32_t mode)
+{
+ switch (mode) {
+ case DEVLINK_ESWITCH_INLINE_MODE_NONE:
+ return ESWITCH_INLINE_MODE_NONE;
+ case DEVLINK_ESWITCH_INLINE_MODE_LINK:
+ return ESWITCH_INLINE_MODE_LINK;
+ case DEVLINK_ESWITCH_INLINE_MODE_NETWORK:
+ return ESWITCH_INLINE_MODE_NETWORK;
+ case DEVLINK_ESWITCH_INLINE_MODE_TRANSPORT:
+ return ESWITCH_INLINE_MODE_TRANSPORT;
+ default:
+ return "<unknown mode>";
+ }
+}
+
static void pr_out_eswitch(struct dl *dl, struct nlattr **tb)
{
__pr_out_handle_start(dl, tb, true, false);
@@ -1210,6 +1276,12 @@ static void pr_out_eswitch(struct dl *dl, struct nlattr **tb)
if (tb[DEVLINK_ATTR_ESWITCH_MODE])
pr_out_str(dl, "mode",
eswitch_mode_name(mnl_attr_get_u16(tb[DEVLINK_ATTR_ESWITCH_MODE])));
+
+ if (tb[DEVLINK_ATTR_ESWITCH_INLINE_MODE])
+ pr_out_str(dl, "inline-mode",
+ eswitch_inline_mode_name(mnl_attr_get_u8(
+ tb[DEVLINK_ATTR_ESWITCH_INLINE_MODE])));
+
pr_out_handle_end(dl);
}
@@ -1252,10 +1324,18 @@ static int cmd_dev_eswitch_set(struct dl *dl)
nlh = mnlg_msg_prepare(dl->nlg, DEVLINK_CMD_ESWITCH_MODE_SET,
NLM_F_REQUEST | NLM_F_ACK);
- err = dl_argv_parse_put(nlh, dl, DL_OPT_HANDLE | DL_OPT_ESWITCH_MODE, 0);
+ err = dl_argv_parse_put(nlh, dl, DL_OPT_HANDLE,
+ DL_OPT_ESWITCH_MODE |
+ DL_OPT_ESWITCH_INLINE_MODE);
+
if (err)
return err;
+ if (dl->opts.present == 1) {
+ pr_err("Need to set at least one option\n");
+ return -ENOENT;
+ }
+
return _mnlg_socket_sndrcv(dl->nlg, nlh, NULL, NULL);
}
diff --git a/include/linux/devlink.h b/include/linux/devlink.h
index b7c1a06..7c14d77 100644
--- a/include/linux/devlink.h
+++ b/include/linux/devlink.h
@@ -102,6 +102,13 @@ enum devlink_eswitch_mode {
DEVLINK_ESWITCH_MODE_SWITCHDEV,
};
+enum devlink_eswitch_inline_mode {
+ DEVLINK_ESWITCH_INLINE_MODE_NONE,
+ DEVLINK_ESWITCH_INLINE_MODE_LINK,
+ DEVLINK_ESWITCH_INLINE_MODE_NETWORK,
+ DEVLINK_ESWITCH_INLINE_MODE_TRANSPORT,
+};
+
enum devlink_attr {
/* don't change the order or add anything between, this is ABI! */
DEVLINK_ATTR_UNSPEC,
@@ -133,6 +140,7 @@ enum devlink_attr {
DEVLINK_ATTR_SB_OCC_CUR, /* u32 */
DEVLINK_ATTR_SB_OCC_MAX, /* u32 */
DEVLINK_ATTR_ESWITCH_MODE, /* u16 */
+ DEVLINK_ATTR_ESWITCH_INLINE_MODE, /* u8 */
/* add new attributes above here, update the policy in devlink.c */
diff --git a/man/man8/devlink-dev.8 b/man/man8/devlink-dev.8
index 931e334..6bfe66f 100644
--- a/man/man8/devlink-dev.8
+++ b/man/man8/devlink-dev.8
@@ -31,6 +31,9 @@ devlink-dev \- devlink device configuration
.RI "[ "
.BR mode " { " legacy " | " switchdev " } "
.RI "]"
+.RI "[ "
+.BR inline-mode " { " none " | " link " | " network " | " transport " } "
+.RI "]"
.ti -8
.BR "devlink dev eswitch show"
@@ -62,6 +65,22 @@ Set eswitch mode
.I switchdev
- SRIOV switchdev offloads
+.TP
+.BR inline-mode " { " none " | " link " | " network " | " transport " } "
+Some HWs need the VF driver to put part of the packet headers on the TX descriptor so the e-switch can do proper matching and steering.
+
+.I none
+- None
+
+.I link
+- L2 mode
+
+.I network
+- L3 mode
+
+.I transport
+- L4 mode
+
.SH "EXAMPLES"
.PP
devlink dev show
--
1.7.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH iproute2 0/2] Adding help and inline mode control to eswitch
2016-11-27 11:21 [PATCH iproute2 0/2] Adding help and inline mode control to eswitch Roi Dayan
2016-11-27 11:21 ` [PATCH iproute2 1/2] devlink: Add usage help for eswitch subcommand Roi Dayan
2016-11-27 11:21 ` [PATCH iproute2 2/2] devlink: Add option to set and show eswitch inline mode Roi Dayan
@ 2016-11-27 11:30 ` Roi Dayan
2 siblings, 0 replies; 5+ messages in thread
From: Roi Dayan @ 2016-11-27 11:30 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: roid, netdev, Or Gerlitz
Hi Stephen,
I forgot to mention that the patches are for net-next branch of iproute2.
Thanks,
Roi
On 27/11/2016 13:21, Roi Dayan wrote:
> Hi,
>
> The first patch is adding missing help message for eswitch.
> The second patch is adding functionality to show/modify eswitch inline mode.
>
> Thanks,
> Roi
>
>
> Roi Dayan (2):
> devlink: Add usage help for eswitch subcommand
> devlink: Add option to set and show eswitch inline mode
>
> devlink/devlink.c | 89 +++++++++++++++++++++++++++++++++++++++++++++-
> include/linux/devlink.h | 8 ++++
> man/man8/devlink-dev.8 | 21 ++++++++++-
> 3 files changed, 115 insertions(+), 3 deletions(-)
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH iproute2 1/2] devlink: Add usage help for eswitch subcommand
2016-11-27 11:21 ` [PATCH iproute2 1/2] devlink: Add usage help for eswitch subcommand Roi Dayan
@ 2016-11-30 3:19 ` Stephen Hemminger
0 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2016-11-30 3:19 UTC (permalink / raw)
To: Roi Dayan; +Cc: netdev, Or Gerlitz
On Sun, 27 Nov 2016 13:21:02 +0200
Roi Dayan <roid@mellanox.com> wrote:
> Add missing usage help for devlink dev eswitch subcommand.
>
> Signed-off-by: Roi Dayan <roid@mellanox.com>
> Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
Ok. Applied both, will show in next merge
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-11-30 3:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-27 11:21 [PATCH iproute2 0/2] Adding help and inline mode control to eswitch Roi Dayan
2016-11-27 11:21 ` [PATCH iproute2 1/2] devlink: Add usage help for eswitch subcommand Roi Dayan
2016-11-30 3:19 ` Stephen Hemminger
2016-11-27 11:21 ` [PATCH iproute2 2/2] devlink: Add option to set and show eswitch inline mode Roi Dayan
2016-11-27 11:30 ` [PATCH iproute2 0/2] Adding help and inline mode control to eswitch Roi Dayan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).