Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 
0003 #ifndef _BR_PRIVATE_MRP_H_
0004 #define _BR_PRIVATE_MRP_H_
0005 
0006 #include "br_private.h"
0007 #include <uapi/linux/mrp_bridge.h>
0008 
0009 #define MRP_OPT_PADDING     0x2
0010 
0011 struct br_mrp {
0012     /* list of mrp instances */
0013     struct hlist_node       list;
0014 
0015     struct net_bridge_port __rcu    *p_port;
0016     struct net_bridge_port __rcu    *s_port;
0017     struct net_bridge_port __rcu    *i_port;
0018 
0019     u32             ring_id;
0020     u16             in_id;
0021     u16             prio;
0022 
0023     enum br_mrp_ring_role_type  ring_role;
0024     u8              ring_role_offloaded;
0025     enum br_mrp_ring_state_type ring_state;
0026     u32             ring_transitions;
0027 
0028     enum br_mrp_in_role_type    in_role;
0029     u8              in_role_offloaded;
0030     enum br_mrp_in_state_type   in_state;
0031     u32             in_transitions;
0032 
0033     struct delayed_work     test_work;
0034     u32             test_interval;
0035     unsigned long           test_end;
0036     u32             test_count_miss;
0037     u32             test_max_miss;
0038     bool                test_monitor;
0039 
0040     struct delayed_work     in_test_work;
0041     u32             in_test_interval;
0042     unsigned long           in_test_end;
0043     u32             in_test_count_miss;
0044     u32             in_test_max_miss;
0045 
0046     u32             seq_id;
0047 
0048     struct rcu_head         rcu;
0049 };
0050 
0051 /* This type is returned by br_mrp_switchdev functions that allow to have a SW
0052  * backup in case the HW can't implement completely the protocol.
0053  * BR_MRP_NONE - means the HW can't run at all the protocol, so the SW stops
0054  *               configuring the node anymore.
0055  * BR_MRP_SW - the HW can help the SW to run the protocol, by redirecting MRP
0056  *             frames to CPU.
0057  * BR_MRP_HW - the HW can implement completely the protocol.
0058  */
0059 enum br_mrp_hw_support {
0060     BR_MRP_NONE,
0061     BR_MRP_SW,
0062     BR_MRP_HW,
0063 };
0064 
0065 /* br_mrp.c */
0066 int br_mrp_add(struct net_bridge *br, struct br_mrp_instance *instance);
0067 int br_mrp_del(struct net_bridge *br, struct br_mrp_instance *instance);
0068 int br_mrp_set_port_state(struct net_bridge_port *p,
0069               enum br_mrp_port_state_type state);
0070 int br_mrp_set_port_role(struct net_bridge_port *p,
0071              enum br_mrp_port_role_type role);
0072 int br_mrp_set_ring_state(struct net_bridge *br,
0073               struct br_mrp_ring_state *state);
0074 int br_mrp_set_ring_role(struct net_bridge *br, struct br_mrp_ring_role *role);
0075 int br_mrp_start_test(struct net_bridge *br, struct br_mrp_start_test *test);
0076 int br_mrp_set_in_state(struct net_bridge *br, struct br_mrp_in_state *state);
0077 int br_mrp_set_in_role(struct net_bridge *br, struct br_mrp_in_role *role);
0078 int br_mrp_start_in_test(struct net_bridge *br,
0079              struct br_mrp_start_in_test *test);
0080 
0081 /* br_mrp_switchdev.c */
0082 int br_mrp_switchdev_add(struct net_bridge *br, struct br_mrp *mrp);
0083 int br_mrp_switchdev_del(struct net_bridge *br, struct br_mrp *mrp);
0084 enum br_mrp_hw_support
0085 br_mrp_switchdev_set_ring_role(struct net_bridge *br, struct br_mrp *mrp,
0086                    enum br_mrp_ring_role_type role);
0087 int br_mrp_switchdev_set_ring_state(struct net_bridge *br, struct br_mrp *mrp,
0088                     enum br_mrp_ring_state_type state);
0089 enum br_mrp_hw_support
0090 br_mrp_switchdev_send_ring_test(struct net_bridge *br, struct br_mrp *mrp,
0091                 u32 interval, u8 max_miss, u32 period,
0092                 bool monitor);
0093 int br_mrp_port_switchdev_set_state(struct net_bridge_port *p, u32 state);
0094 int br_mrp_port_switchdev_set_role(struct net_bridge_port *p,
0095                    enum br_mrp_port_role_type role);
0096 enum br_mrp_hw_support
0097 br_mrp_switchdev_set_in_role(struct net_bridge *br, struct br_mrp *mrp,
0098                  u16 in_id, u32 ring_id,
0099                  enum br_mrp_in_role_type role);
0100 int br_mrp_switchdev_set_in_state(struct net_bridge *br, struct br_mrp *mrp,
0101                   enum br_mrp_in_state_type state);
0102 enum br_mrp_hw_support
0103 br_mrp_switchdev_send_in_test(struct net_bridge *br, struct br_mrp *mrp,
0104                   u32 interval, u8 max_miss, u32 period);
0105 
0106 /* br_mrp_netlink.c  */
0107 int br_mrp_ring_port_open(struct net_device *dev, u8 loc);
0108 int br_mrp_in_port_open(struct net_device *dev, u8 loc);
0109 
0110 /* MRP protocol data units */
0111 struct br_mrp_tlv_hdr {
0112     __u8 type;
0113     __u8 length;
0114 };
0115 
0116 struct br_mrp_common_hdr {
0117     __be16 seq_id;
0118     __u8 domain[MRP_DOMAIN_UUID_LENGTH];
0119 };
0120 
0121 struct br_mrp_ring_test_hdr {
0122     __be16 prio;
0123     __u8 sa[ETH_ALEN];
0124     __be16 port_role;
0125     __be16 state;
0126     __be16 transitions;
0127     __be32 timestamp;
0128 } __attribute__((__packed__));
0129 
0130 struct br_mrp_in_test_hdr {
0131     __be16 id;
0132     __u8 sa[ETH_ALEN];
0133     __be16 port_role;
0134     __be16 state;
0135     __be16 transitions;
0136     __be32 timestamp;
0137 } __attribute__((__packed__));
0138 
0139 struct br_mrp_oui_hdr {
0140     __u8 oui[MRP_OUI_LENGTH];
0141 };
0142 
0143 struct br_mrp_sub_option1_hdr {
0144     __u8 type;
0145     __u8 data[MRP_MANUFACTURE_DATA_LENGTH];
0146 };
0147 
0148 #endif /* _BR_PRIVATE_MRP_H */