devlink: Add IPv4 header for dpipe
authorArkadi Sharshevsky <arkadis@mellanox.com>
Thu, 24 Aug 2017 06:40:00 +0000 (08:40 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 24 Aug 2017 16:33:16 +0000 (09:33 -0700)
This will be used by the IPv4 host table which will be introduced in the
following patches. This header is global and can be reused by many
drivers.

Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/devlink.h
include/uapi/linux/devlink.h
net/core/devlink.c

index ddb8b5227580f8d623ebad19167ab6300ff038ae..8ff8a6f77f29b94179047c5c805bb1d9028eb7fc 100644 (file)
@@ -329,6 +329,7 @@ int devlink_dpipe_action_put(struct sk_buff *skb,
 int devlink_dpipe_match_put(struct sk_buff *skb,
                            struct devlink_dpipe_match *match);
 extern struct devlink_dpipe_header devlink_dpipe_header_ethernet;
+extern struct devlink_dpipe_header devlink_dpipe_header_ipv4;
 
 #else
 
index a855f8dcc8eea54d72be24d3b2299bfcd1bd5895..6c172548589dedd184824a9ce1c15d89d7479458 100644 (file)
@@ -230,8 +230,13 @@ enum devlink_dpipe_field_ethernet_id {
        DEVLINK_DPIPE_FIELD_ETHERNET_DST_MAC,
 };
 
+enum devlink_dpipe_field_ipv4_id {
+       DEVLINK_DPIPE_FIELD_IPV4_DST_IP,
+};
+
 enum devlink_dpipe_header_id {
        DEVLINK_DPIPE_HEADER_ETHERNET,
+       DEVLINK_DPIPE_HEADER_IPV4,
 };
 
 #endif /* _UAPI_LINUX_DEVLINK_H_ */
index 4f6f3d601785ce6fa2a0721c24859ae34a8da0b9..fcf5dd6628820c9169e21802b97c665b59745b44 100644 (file)
@@ -46,6 +46,23 @@ struct devlink_dpipe_header devlink_dpipe_header_ethernet = {
 };
 EXPORT_SYMBOL(devlink_dpipe_header_ethernet);
 
+static struct devlink_dpipe_field devlink_dpipe_fields_ipv4[] = {
+       {
+               .name = "destination ip",
+               .id = DEVLINK_DPIPE_FIELD_IPV4_DST_IP,
+               .bitwidth = 32,
+       },
+};
+
+struct devlink_dpipe_header devlink_dpipe_header_ipv4 = {
+       .name = "ipv4",
+       .id = DEVLINK_DPIPE_HEADER_IPV4,
+       .fields = devlink_dpipe_fields_ipv4,
+       .fields_count = ARRAY_SIZE(devlink_dpipe_fields_ipv4),
+       .global = true,
+};
+EXPORT_SYMBOL(devlink_dpipe_header_ipv4);
+
 EXPORT_TRACEPOINT_SYMBOL_GPL(devlink_hwmsg);
 
 static LIST_HEAD(devlink_list);