Re: [very-RFC 5/8] Add TSN machinery to drive the traffic from a shim over the network
On Sun, Jun 12, 2016 at 12:35:10AM -0700, Joe Perches wrote: > On Sun, 2016-06-12 at 00:22 +0200, Henrik Austad wrote: > > From: Henrik Austad> > > > In short summary: > > > > * tsn_core.c is the main driver of tsn, all new links go through > > here and all data to/form the shims are handled here > > core also manages the shim-interface. > [] > > diff --git a/net/tsn/tsn_configfs.c b/net/tsn/tsn_configfs.c > [] > > +static inline struct tsn_link *to_tsn_link(struct config_item *item) > > +{ > > + /* this line causes checkpatch to WARN. making checkpatch happy, > > + * makes code messy.. > > + */ > > + return item ? container_of(to_config_group(item), struct tsn_link, > > group) : NULL; > > +} > > How about > > static inline struct tsn_link *to_tsn_link(struct config_item *item) > { > if (!item) > return NULL; > return container_of(to_config_group(item), struct tsn_link, group); > } Yes, I mulled over this for a while, but I got the impression that the ternary-approach was the way used in configfs, and I tried staying in line with that in tsn_configfs. If you see other parts of the TSN-code, I tend to use the if (!item) ... approach. So, I don't have any technical preferences either way really -- Henrik Austad signature.asc Description: Digital signature
Re: [very-RFC 5/8] Add TSN machinery to drive the traffic from a shim over the network
On Sun, 2016-06-12 at 00:22 +0200, Henrik Austad wrote: > From: Henrik Austad> > In short summary: > > * tsn_core.c is the main driver of tsn, all new links go through > here and all data to/form the shims are handled here > core also manages the shim-interface. [] > diff --git a/net/tsn/tsn_configfs.c b/net/tsn/tsn_configfs.c [] > +static inline struct tsn_link *to_tsn_link(struct config_item *item) > +{ > + /* this line causes checkpatch to WARN. making checkpatch happy, > + * makes code messy.. > + */ > + return item ? container_of(to_config_group(item), struct tsn_link, > group) : NULL; > +} How about static inline struct tsn_link *to_tsn_link(struct config_item *item) { if (!item) return NULL; return container_of(to_config_group(item), struct tsn_link, group); } -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[very-RFC 5/8] Add TSN machinery to drive the traffic from a shim over the network
From: Henrik AustadIn short summary: * tsn_core.c is the main driver of tsn, all new links go through here and all data to/form the shims are handled here core also manages the shim-interface. * tsn_configfs.c is the API to userspace. TSN is driven from userspace and a link is created, configured, enabled, disabled and removed purely from userspace. All attributes requried must be determined by userspace, preferrably via IEEE 1722.1 (discovery and enumeration). * tsn_header.c small part that handles the actual header of the frames we send. Kept out of core for cleanliness. * tsn_net.c handles operations towards the networking layer. The current driver is under development. This means that from the moment it is enabled with a shim, it will send traffic, either 0-traffic (frames of reserved length but with payload 0) or actual traffic. This will change once the driver stabilizes. For more detail, see Documentation/networking/tsn/ Cc: "David S. Miller" Signed-off-by: Henrik Austad --- net/Makefile | 1 + net/tsn/Makefile | 6 + net/tsn/tsn_configfs.c | 623 +++ net/tsn/tsn_core.c | 975 + net/tsn/tsn_header.c | 203 ++ net/tsn/tsn_internal.h | 383 +++ net/tsn/tsn_net.c | 403 7 files changed, 2594 insertions(+) create mode 100644 net/tsn/Makefile create mode 100644 net/tsn/tsn_configfs.c create mode 100644 net/tsn/tsn_core.c create mode 100644 net/tsn/tsn_header.c create mode 100644 net/tsn/tsn_internal.h create mode 100644 net/tsn/tsn_net.c diff --git a/net/Makefile b/net/Makefile index bdd1455..c15482e 100644 --- a/net/Makefile +++ b/net/Makefile @@ -79,3 +79,4 @@ ifneq ($(CONFIG_NET_L3_MASTER_DEV),) obj-y += l3mdev/ endif obj-$(CONFIG_QRTR) += qrtr/ +obj-$(CONFIG_TSN) += tsn/ diff --git a/net/tsn/Makefile b/net/tsn/Makefile new file mode 100644 index 000..0d87687 --- /dev/null +++ b/net/tsn/Makefile @@ -0,0 +1,6 @@ +# +# Makefile for the Linux TSN subsystem +# + +obj-$(CONFIG_TSN) += tsn.o +tsn-objs :=tsn_core.o tsn_configfs.o tsn_net.o tsn_header.o diff --git a/net/tsn/tsn_configfs.c b/net/tsn/tsn_configfs.c new file mode 100644 index 000..f3d0986 --- /dev/null +++ b/net/tsn/tsn_configfs.c @@ -0,0 +1,623 @@ +/* + * ConfigFS interface to TSN + * Copyright (C) 2015- Henrik Austad + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#include +#include +#include +#include +#include +#include +#include +#include "tsn_internal.h" + +static inline struct tsn_link *to_tsn_link(struct config_item *item) +{ + /* this line causes checkpatch to WARN. making checkpatch happy, +* makes code messy.. +*/ + return item ? container_of(to_config_group(item), struct tsn_link, group) : NULL; +} + +static inline struct tsn_nic *to_tsn_nic(struct config_group *group) +{ + return group ? container_of(group, struct tsn_nic, group) : NULL; +} + +/* --- + * Tier2 attributes + * + * The content of the links userspace can see/modify + * --- +*/ +static ssize_t _tsn_max_payload_size_show(struct config_item *item, + char *page) +{ + struct tsn_link *link = to_tsn_link(item); + + if (!link) + return -EINVAL; + return sprintf(page, "%u\n", (u32)link->max_payload_size); +} + +static ssize_t _tsn_max_payload_size_store(struct config_item *item, + const char *page, size_t count) +{ + struct tsn_link *link = to_tsn_link(item); + u16 mpl_size = 0; + int ret = 0; + + if (!link) + return -EINVAL; + if (tsn_link_is_on(link)) { + pr_err("ERROR: Cannot change Payload size on on enabled link\n"); + return -EINVAL; + } + ret = kstrtou16(page, 0, _size); + if (ret) + return ret; + + /* 802.1BA-2011 6.4 payload must be <1500 octets (excluding +* headers, tags etc) However, this is not directly mappable to +* how some hw handles things, so to be conservative, we +* restrict it down to [26..1485] +* +* This is also the _payload_ size, which does not include the +
Re: [very-RFC 5/8] Add TSN machinery to drive the traffic from a shim over the network
clearing up netdev-typo -H On Sun, Jun 12, 2016 at 12:22:18AM +0200, Henrik Austad wrote: > From: Henrik Austad> > In short summary: > > * tsn_core.c is the main driver of tsn, all new links go through > here and all data to/form the shims are handled here > core also manages the shim-interface. > > * tsn_configfs.c is the API to userspace. TSN is driven from userspace > and a link is created, configured, enabled, disabled and removed > purely from userspace. All attributes requried must be determined by > userspace, preferrably via IEEE 1722.1 (discovery and enumeration). > > * tsn_header.c small part that handles the actual header of the frames > we send. Kept out of core for cleanliness. > > * tsn_net.c handles operations towards the networking layer. > > The current driver is under development. This means that from the moment it > is enabled with a shim, it will send traffic, either 0-traffic (frames of > reserved length but with payload 0) or actual traffic. This will change > once the driver stabilizes. > > For more detail, see Documentation/networking/tsn/ > > Cc: "David S. Miller" > Signed-off-by: Henrik Austad > --- > net/Makefile | 1 + > net/tsn/Makefile | 6 + > net/tsn/tsn_configfs.c | 623 +++ > net/tsn/tsn_core.c | 975 > + > net/tsn/tsn_header.c | 203 ++ > net/tsn/tsn_internal.h | 383 +++ > net/tsn/tsn_net.c | 403 > 7 files changed, 2594 insertions(+) > create mode 100644 net/tsn/Makefile > create mode 100644 net/tsn/tsn_configfs.c > create mode 100644 net/tsn/tsn_core.c > create mode 100644 net/tsn/tsn_header.c > create mode 100644 net/tsn/tsn_internal.h > create mode 100644 net/tsn/tsn_net.c > > diff --git a/net/Makefile b/net/Makefile > index bdd1455..c15482e 100644 > --- a/net/Makefile > +++ b/net/Makefile > @@ -79,3 +79,4 @@ ifneq ($(CONFIG_NET_L3_MASTER_DEV),) > obj-y+= l3mdev/ > endif > obj-$(CONFIG_QRTR) += qrtr/ > +obj-$(CONFIG_TSN)+= tsn/ > diff --git a/net/tsn/Makefile b/net/tsn/Makefile > new file mode 100644 > index 000..0d87687 > --- /dev/null > +++ b/net/tsn/Makefile > @@ -0,0 +1,6 @@ > +# > +# Makefile for the Linux TSN subsystem > +# > + > +obj-$(CONFIG_TSN) += tsn.o > +tsn-objs :=tsn_core.o tsn_configfs.o tsn_net.o tsn_header.o > diff --git a/net/tsn/tsn_configfs.c b/net/tsn/tsn_configfs.c > new file mode 100644 > index 000..f3d0986 > --- /dev/null > +++ b/net/tsn/tsn_configfs.c > @@ -0,0 +1,623 @@ > +/* > + * ConfigFS interface to TSN > + * Copyright (C) 2015- Henrik Austad > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + */ > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include "tsn_internal.h" > + > +static inline struct tsn_link *to_tsn_link(struct config_item *item) > +{ > + /* this line causes checkpatch to WARN. making checkpatch happy, > + * makes code messy.. > + */ > + return item ? container_of(to_config_group(item), struct tsn_link, > group) : NULL; > +} > + > +static inline struct tsn_nic *to_tsn_nic(struct config_group *group) > +{ > + return group ? container_of(group, struct tsn_nic, group) : NULL; > +} > + > +/* --- > + * Tier2 attributes > + * > + * The content of the links userspace can see/modify > + * --- > +*/ > +static ssize_t _tsn_max_payload_size_show(struct config_item *item, > + char *page) > +{ > + struct tsn_link *link = to_tsn_link(item); > + > + if (!link) > + return -EINVAL; > + return sprintf(page, "%u\n", (u32)link->max_payload_size); > +} > + > +static ssize_t _tsn_max_payload_size_store(struct config_item *item, > +const char *page, size_t count) > +{ > + struct tsn_link *link = to_tsn_link(item); > + u16 mpl_size = 0; > + int ret = 0; > + > + if (!link) > + return -EINVAL; > + if (tsn_link_is_on(link)) { > + pr_err("ERROR: Cannot change Payload size on on enabled > link\n"); > + return -EINVAL; > + } > + ret = kstrtou16(page, 0, _size); > + if (ret) > + return ret; > + > +
[very-RFC 5/8] Add TSN machinery to drive the traffic from a shim over the network
From: Henrik AustadIn short summary: * tsn_core.c is the main driver of tsn, all new links go through here and all data to/form the shims are handled here core also manages the shim-interface. * tsn_configfs.c is the API to userspace. TSN is driven from userspace and a link is created, configured, enabled, disabled and removed purely from userspace. All attributes requried must be determined by userspace, preferrably via IEEE 1722.1 (discovery and enumeration). * tsn_header.c small part that handles the actual header of the frames we send. Kept out of core for cleanliness. * tsn_net.c handles operations towards the networking layer. The current driver is under development. This means that from the moment it is enabled with a shim, it will send traffic, either 0-traffic (frames of reserved length but with payload 0) or actual traffic. This will change once the driver stabilizes. For more detail, see Documentation/networking/tsn/ Cc: "David S. Miller" Signed-off-by: Henrik Austad --- net/Makefile | 1 + net/tsn/Makefile | 6 + net/tsn/tsn_configfs.c | 623 +++ net/tsn/tsn_core.c | 975 + net/tsn/tsn_header.c | 203 ++ net/tsn/tsn_internal.h | 383 +++ net/tsn/tsn_net.c | 403 7 files changed, 2594 insertions(+) create mode 100644 net/tsn/Makefile create mode 100644 net/tsn/tsn_configfs.c create mode 100644 net/tsn/tsn_core.c create mode 100644 net/tsn/tsn_header.c create mode 100644 net/tsn/tsn_internal.h create mode 100644 net/tsn/tsn_net.c diff --git a/net/Makefile b/net/Makefile index bdd1455..c15482e 100644 --- a/net/Makefile +++ b/net/Makefile @@ -79,3 +79,4 @@ ifneq ($(CONFIG_NET_L3_MASTER_DEV),) obj-y += l3mdev/ endif obj-$(CONFIG_QRTR) += qrtr/ +obj-$(CONFIG_TSN) += tsn/ diff --git a/net/tsn/Makefile b/net/tsn/Makefile new file mode 100644 index 000..0d87687 --- /dev/null +++ b/net/tsn/Makefile @@ -0,0 +1,6 @@ +# +# Makefile for the Linux TSN subsystem +# + +obj-$(CONFIG_TSN) += tsn.o +tsn-objs :=tsn_core.o tsn_configfs.o tsn_net.o tsn_header.o diff --git a/net/tsn/tsn_configfs.c b/net/tsn/tsn_configfs.c new file mode 100644 index 000..f3d0986 --- /dev/null +++ b/net/tsn/tsn_configfs.c @@ -0,0 +1,623 @@ +/* + * ConfigFS interface to TSN + * Copyright (C) 2015- Henrik Austad + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#include +#include +#include +#include +#include +#include +#include +#include "tsn_internal.h" + +static inline struct tsn_link *to_tsn_link(struct config_item *item) +{ + /* this line causes checkpatch to WARN. making checkpatch happy, +* makes code messy.. +*/ + return item ? container_of(to_config_group(item), struct tsn_link, group) : NULL; +} + +static inline struct tsn_nic *to_tsn_nic(struct config_group *group) +{ + return group ? container_of(group, struct tsn_nic, group) : NULL; +} + +/* --- + * Tier2 attributes + * + * The content of the links userspace can see/modify + * --- +*/ +static ssize_t _tsn_max_payload_size_show(struct config_item *item, + char *page) +{ + struct tsn_link *link = to_tsn_link(item); + + if (!link) + return -EINVAL; + return sprintf(page, "%u\n", (u32)link->max_payload_size); +} + +static ssize_t _tsn_max_payload_size_store(struct config_item *item, + const char *page, size_t count) +{ + struct tsn_link *link = to_tsn_link(item); + u16 mpl_size = 0; + int ret = 0; + + if (!link) + return -EINVAL; + if (tsn_link_is_on(link)) { + pr_err("ERROR: Cannot change Payload size on on enabled link\n"); + return -EINVAL; + } + ret = kstrtou16(page, 0, _size); + if (ret) + return ret; + + /* 802.1BA-2011 6.4 payload must be <1500 octets (excluding +* headers, tags etc) However, this is not directly mappable to +* how some hw handles things, so to be conservative, we +* restrict it down to [26..1485] +* +* This is also the _payload_ size, which does not include the +