Merge branch 'for-4.2/writeback' of git://git.kernel.dk/linux-block
[firefly-linux-kernel-4.4.55.git] / include / net / switchdev.h
index 397b1e6e04f6ba3b311db5f7088c142e6064c18a..d5671f118bfc54566a34d48708e35b69af19b417 100644 (file)
@@ -38,7 +38,7 @@ struct switchdev_attr {
                struct netdev_phys_item_id ppid;        /* PORT_PARENT_ID */
                u8 stp_state;                           /* PORT_STP_STATE */
                unsigned long brport_flags;             /* PORT_BRIDGE_FLAGS */
-       };
+       } u;
 };
 
 struct fib_info;
@@ -46,18 +46,34 @@ struct fib_info;
 enum switchdev_obj_id {
        SWITCHDEV_OBJ_UNDEFINED,
        SWITCHDEV_OBJ_PORT_VLAN,
+       SWITCHDEV_OBJ_IPV4_FIB,
+       SWITCHDEV_OBJ_PORT_FDB,
 };
 
 struct switchdev_obj {
        enum switchdev_obj_id id;
        enum switchdev_trans trans;
+       int (*cb)(struct net_device *dev, struct switchdev_obj *obj);
        union {
-               struct switchdev_obj_vlan {                     /* PORT_VLAN */
+               struct switchdev_obj_vlan {             /* PORT_VLAN */
                        u16 flags;
-                       u16 vid_start;
+                       u16 vid_begin;
                        u16 vid_end;
                } vlan;
-       };
+               struct switchdev_obj_ipv4_fib {         /* IPV4_FIB */
+                       u32 dst;
+                       int dst_len;
+                       struct fib_info *fi;
+                       u8 tos;
+                       u8 type;
+                       u32 nlflags;
+                       u32 tb_id;
+               } ipv4_fib;
+               struct switchdev_obj_fdb {              /* PORT_FDB */
+                       const unsigned char *addr;
+                       u16 vid;
+               } fdb;
+       } u;
 };
 
 /**
@@ -71,9 +87,7 @@ struct switchdev_obj {
  *
  * @switchdev_port_obj_del: Delete an object from port (see switchdev_obj).
  *
- * @switchdev_fib_ipv4_add: Called to add/modify IPv4 route to switch device.
- *
- * @switchdev_fib_ipv4_del: Called to delete IPv4 route from switch device.
+ * @switchdev_port_obj_dump: Dump port objects (see switchdev_obj).
  */
 struct switchdev_ops {
        int     (*switchdev_port_attr_get)(struct net_device *dev,
@@ -84,13 +98,8 @@ struct switchdev_ops {
                                          struct switchdev_obj *obj);
        int     (*switchdev_port_obj_del)(struct net_device *dev,
                                          struct switchdev_obj *obj);
-       int     (*switchdev_fib_ipv4_add)(struct net_device *dev, __be32 dst,
-                                         int dst_len, struct fib_info *fi,
-                                         u8 tos, u8 type, u32 nlflags,
-                                         u32 tb_id);
-       int     (*switchdev_fib_ipv4_del)(struct net_device *dev, __be32 dst,
-                                         int dst_len, struct fib_info *fi,
-                                         u8 tos, u8 type, u32 tb_id);
+       int     (*switchdev_port_obj_dump)(struct net_device *dev,
+                                         struct switchdev_obj *obj);
 };
 
 enum switchdev_notifier_type {
@@ -122,10 +131,14 @@ int switchdev_port_attr_set(struct net_device *dev,
                            struct switchdev_attr *attr);
 int switchdev_port_obj_add(struct net_device *dev, struct switchdev_obj *obj);
 int switchdev_port_obj_del(struct net_device *dev, struct switchdev_obj *obj);
+int switchdev_port_obj_dump(struct net_device *dev, struct switchdev_obj *obj);
 int register_switchdev_notifier(struct notifier_block *nb);
 int unregister_switchdev_notifier(struct notifier_block *nb);
 int call_switchdev_notifiers(unsigned long val, struct net_device *dev,
                             struct switchdev_notifier_info *info);
+int switchdev_port_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
+                                 struct net_device *dev, u32 filter_mask,
+                                 int nlflags);
 int switchdev_port_bridge_setlink(struct net_device *dev,
                                  struct nlmsghdr *nlh, u16 flags);
 int switchdev_port_bridge_dellink(struct net_device *dev,
@@ -135,6 +148,15 @@ int switchdev_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi,
 int switchdev_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi,
                           u8 tos, u8 type, u32 tb_id);
 void switchdev_fib_ipv4_abort(struct fib_info *fi);
+int switchdev_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
+                          struct net_device *dev, const unsigned char *addr,
+                          u16 vid, u16 nlm_flags);
+int switchdev_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
+                          struct net_device *dev, const unsigned char *addr,
+                          u16 vid);
+int switchdev_port_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,
+                           struct net_device *dev,
+                           struct net_device *filter_dev, int idx);
 
 #else
 
@@ -162,6 +184,12 @@ static inline int switchdev_port_obj_del(struct net_device *dev,
        return -EOPNOTSUPP;
 }
 
+static inline int switchdev_port_obj_dump(struct net_device *dev,
+                                         struct switchdev_obj *obj)
+{
+       return -EOPNOTSUPP;
+}
+
 static inline int register_switchdev_notifier(struct notifier_block *nb)
 {
        return 0;
@@ -179,6 +207,13 @@ static inline int call_switchdev_notifiers(unsigned long val,
        return NOTIFY_DONE;
 }
 
+static inline int switchdev_port_bridge_getlink(struct sk_buff *skb, u32 pid,
+                                           u32 seq, struct net_device *dev,
+                                           u32 filter_mask, int nlflags)
+{
+       return -EOPNOTSUPP;
+}
+
 static inline int switchdev_port_bridge_setlink(struct net_device *dev,
                                                struct nlmsghdr *nlh,
                                                u16 flags)
@@ -212,6 +247,30 @@ static inline void switchdev_fib_ipv4_abort(struct fib_info *fi)
 {
 }
 
+static inline int switchdev_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
+                                        struct net_device *dev,
+                                        const unsigned char *addr,
+                                        u16 vid, u16 nlm_flags)
+{
+       return -EOPNOTSUPP;
+}
+
+static inline int switchdev_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
+                                        struct net_device *dev,
+                                        const unsigned char *addr, u16 vid)
+{
+       return -EOPNOTSUPP;
+}
+
+static inline int switchdev_port_fdb_dump(struct sk_buff *skb,
+                                         struct netlink_callback *cb,
+                                         struct net_device *dev,
+                                         struct net_device *filter_dev,
+                                         int idx)
+{
+       return -EOPNOTSUPP;
+}
+
 #endif
 
 #endif /* _LINUX_SWITCHDEV_H_ */