spectrum.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. /*
  2. * drivers/net/ethernet/mellanox/mlxsw/spectrum.h
  3. * Copyright (c) 2015-2017 Mellanox Technologies. All rights reserved.
  4. * Copyright (c) 2015-2017 Jiri Pirko <jiri@mellanox.com>
  5. * Copyright (c) 2015 Ido Schimmel <idosch@mellanox.com>
  6. * Copyright (c) 2015 Elad Raz <eladr@mellanox.com>
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. * 3. Neither the names of the copyright holders nor the names of its
  17. * contributors may be used to endorse or promote products derived from
  18. * this software without specific prior written permission.
  19. *
  20. * Alternatively, this software may be distributed under the terms of the
  21. * GNU General Public License ("GPL") version 2 as published by the Free
  22. * Software Foundation.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  27. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  28. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  29. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  30. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  31. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  32. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  33. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  34. * POSSIBILITY OF SUCH DAMAGE.
  35. */
  36. #ifndef _MLXSW_SPECTRUM_H
  37. #define _MLXSW_SPECTRUM_H
  38. #include <linux/types.h>
  39. #include <linux/netdevice.h>
  40. #include <linux/rhashtable.h>
  41. #include <linux/bitops.h>
  42. #include <linux/if_vlan.h>
  43. #include <linux/list.h>
  44. #include <linux/dcbnl.h>
  45. #include <linux/in6.h>
  46. #include <linux/notifier.h>
  47. #include <net/psample.h>
  48. #include <net/pkt_cls.h>
  49. #include "port.h"
  50. #include "core.h"
  51. #include "core_acl_flex_keys.h"
  52. #include "core_acl_flex_actions.h"
  53. #define MLXSW_SP_FID_8021D_MAX 1024
  54. #define MLXSW_SP_MID_MAX 7000
  55. #define MLXSW_SP_PORTS_PER_CLUSTER_MAX 4
  56. #define MLXSW_SP_PORT_BASE_SPEED 25000 /* Mb/s */
  57. #define MLXSW_SP_KVD_LINEAR_SIZE 65536 /* entries */
  58. #define MLXSW_SP_KVD_GRANULARITY 128
  59. struct mlxsw_sp_port;
  60. struct mlxsw_sp_rif;
  61. struct mlxsw_sp_upper {
  62. struct net_device *dev;
  63. unsigned int ref_count;
  64. };
  65. enum mlxsw_sp_rif_type {
  66. MLXSW_SP_RIF_TYPE_SUBPORT,
  67. MLXSW_SP_RIF_TYPE_VLAN,
  68. MLXSW_SP_RIF_TYPE_FID,
  69. MLXSW_SP_RIF_TYPE_IPIP_LB, /* IP-in-IP loopback. */
  70. MLXSW_SP_RIF_TYPE_MAX,
  71. };
  72. enum mlxsw_sp_fid_type {
  73. MLXSW_SP_FID_TYPE_8021Q,
  74. MLXSW_SP_FID_TYPE_8021D,
  75. MLXSW_SP_FID_TYPE_RFID,
  76. MLXSW_SP_FID_TYPE_DUMMY,
  77. MLXSW_SP_FID_TYPE_MAX,
  78. };
  79. struct mlxsw_sp_mid {
  80. struct list_head list;
  81. unsigned char addr[ETH_ALEN];
  82. u16 fid;
  83. u16 mid;
  84. unsigned int ref_count;
  85. };
  86. enum mlxsw_sp_span_type {
  87. MLXSW_SP_SPAN_EGRESS,
  88. MLXSW_SP_SPAN_INGRESS
  89. };
  90. struct mlxsw_sp_span_inspected_port {
  91. struct list_head list;
  92. enum mlxsw_sp_span_type type;
  93. u8 local_port;
  94. };
  95. struct mlxsw_sp_span_entry {
  96. u8 local_port;
  97. bool used;
  98. struct list_head bound_ports_list;
  99. int ref_count;
  100. int id;
  101. };
  102. enum mlxsw_sp_port_mall_action_type {
  103. MLXSW_SP_PORT_MALL_MIRROR,
  104. MLXSW_SP_PORT_MALL_SAMPLE,
  105. };
  106. struct mlxsw_sp_port_mall_mirror_tc_entry {
  107. u8 to_local_port;
  108. bool ingress;
  109. };
  110. struct mlxsw_sp_port_mall_tc_entry {
  111. struct list_head list;
  112. unsigned long cookie;
  113. enum mlxsw_sp_port_mall_action_type type;
  114. union {
  115. struct mlxsw_sp_port_mall_mirror_tc_entry mirror;
  116. };
  117. };
  118. struct mlxsw_sp_sb;
  119. struct mlxsw_sp_bridge;
  120. struct mlxsw_sp_router;
  121. struct mlxsw_sp_acl;
  122. struct mlxsw_sp_counter_pool;
  123. struct mlxsw_sp_fid_core;
  124. struct mlxsw_sp {
  125. struct mlxsw_sp_port **ports;
  126. struct mlxsw_core *core;
  127. const struct mlxsw_bus_info *bus_info;
  128. unsigned char base_mac[ETH_ALEN];
  129. struct mlxsw_sp_upper *lags;
  130. u8 *port_to_module;
  131. struct mlxsw_sp_sb *sb;
  132. struct mlxsw_sp_bridge *bridge;
  133. struct mlxsw_sp_router *router;
  134. struct mlxsw_afa *afa;
  135. struct mlxsw_sp_acl *acl;
  136. struct mlxsw_sp_fid_core *fid_core;
  137. struct {
  138. DECLARE_BITMAP(usage, MLXSW_SP_KVD_LINEAR_SIZE);
  139. } kvdl;
  140. struct mlxsw_sp_counter_pool *counter_pool;
  141. struct {
  142. struct mlxsw_sp_span_entry *entries;
  143. int entries_count;
  144. } span;
  145. };
  146. static inline struct mlxsw_sp_upper *
  147. mlxsw_sp_lag_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id)
  148. {
  149. return &mlxsw_sp->lags[lag_id];
  150. }
  151. struct mlxsw_sp_port_pcpu_stats {
  152. u64 rx_packets;
  153. u64 rx_bytes;
  154. u64 tx_packets;
  155. u64 tx_bytes;
  156. struct u64_stats_sync syncp;
  157. u32 tx_dropped;
  158. };
  159. struct mlxsw_sp_port_sample {
  160. struct psample_group __rcu *psample_group;
  161. u32 trunc_size;
  162. u32 rate;
  163. bool truncate;
  164. };
  165. struct mlxsw_sp_bridge_port;
  166. struct mlxsw_sp_fid;
  167. struct mlxsw_sp_port_vlan {
  168. struct list_head list;
  169. struct mlxsw_sp_port *mlxsw_sp_port;
  170. struct mlxsw_sp_fid *fid;
  171. u16 vid;
  172. struct mlxsw_sp_bridge_port *bridge_port;
  173. struct list_head bridge_vlan_node;
  174. };
  175. struct mlxsw_sp_port {
  176. struct net_device *dev;
  177. struct mlxsw_sp_port_pcpu_stats __percpu *pcpu_stats;
  178. struct mlxsw_sp *mlxsw_sp;
  179. u8 local_port;
  180. u8 lagged:1,
  181. split:1;
  182. u16 pvid;
  183. u16 lag_id;
  184. struct {
  185. u8 tx_pause:1,
  186. rx_pause:1,
  187. autoneg:1;
  188. } link;
  189. struct {
  190. struct ieee_ets *ets;
  191. struct ieee_maxrate *maxrate;
  192. struct ieee_pfc *pfc;
  193. } dcb;
  194. struct {
  195. u8 module;
  196. u8 width;
  197. u8 lane;
  198. } mapping;
  199. /* TC handles */
  200. struct list_head mall_tc_list;
  201. struct {
  202. #define MLXSW_HW_STATS_UPDATE_TIME HZ
  203. struct rtnl_link_stats64 *cache;
  204. struct delayed_work update_dw;
  205. } hw_stats;
  206. struct mlxsw_sp_port_sample *sample;
  207. struct list_head vlans_list;
  208. };
  209. static inline bool
  210. mlxsw_sp_port_is_pause_en(const struct mlxsw_sp_port *mlxsw_sp_port)
  211. {
  212. return mlxsw_sp_port->link.tx_pause || mlxsw_sp_port->link.rx_pause;
  213. }
  214. static inline struct mlxsw_sp_port *
  215. mlxsw_sp_port_lagged_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id, u8 port_index)
  216. {
  217. struct mlxsw_sp_port *mlxsw_sp_port;
  218. u8 local_port;
  219. local_port = mlxsw_core_lag_mapping_get(mlxsw_sp->core,
  220. lag_id, port_index);
  221. mlxsw_sp_port = mlxsw_sp->ports[local_port];
  222. return mlxsw_sp_port && mlxsw_sp_port->lagged ? mlxsw_sp_port : NULL;
  223. }
  224. static inline struct mlxsw_sp_port_vlan *
  225. mlxsw_sp_port_vlan_find_by_vid(const struct mlxsw_sp_port *mlxsw_sp_port,
  226. u16 vid)
  227. {
  228. struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan;
  229. list_for_each_entry(mlxsw_sp_port_vlan, &mlxsw_sp_port->vlans_list,
  230. list) {
  231. if (mlxsw_sp_port_vlan->vid == vid)
  232. return mlxsw_sp_port_vlan;
  233. }
  234. return NULL;
  235. }
  236. enum mlxsw_sp_flood_type {
  237. MLXSW_SP_FLOOD_TYPE_UC,
  238. MLXSW_SP_FLOOD_TYPE_BC,
  239. MLXSW_SP_FLOOD_TYPE_MC,
  240. };
  241. /* spectrum_buffers.c */
  242. int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp);
  243. void mlxsw_sp_buffers_fini(struct mlxsw_sp *mlxsw_sp);
  244. int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port);
  245. int mlxsw_sp_sb_pool_get(struct mlxsw_core *mlxsw_core,
  246. unsigned int sb_index, u16 pool_index,
  247. struct devlink_sb_pool_info *pool_info);
  248. int mlxsw_sp_sb_pool_set(struct mlxsw_core *mlxsw_core,
  249. unsigned int sb_index, u16 pool_index, u32 size,
  250. enum devlink_sb_threshold_type threshold_type);
  251. int mlxsw_sp_sb_port_pool_get(struct mlxsw_core_port *mlxsw_core_port,
  252. unsigned int sb_index, u16 pool_index,
  253. u32 *p_threshold);
  254. int mlxsw_sp_sb_port_pool_set(struct mlxsw_core_port *mlxsw_core_port,
  255. unsigned int sb_index, u16 pool_index,
  256. u32 threshold);
  257. int mlxsw_sp_sb_tc_pool_bind_get(struct mlxsw_core_port *mlxsw_core_port,
  258. unsigned int sb_index, u16 tc_index,
  259. enum devlink_sb_pool_type pool_type,
  260. u16 *p_pool_index, u32 *p_threshold);
  261. int mlxsw_sp_sb_tc_pool_bind_set(struct mlxsw_core_port *mlxsw_core_port,
  262. unsigned int sb_index, u16 tc_index,
  263. enum devlink_sb_pool_type pool_type,
  264. u16 pool_index, u32 threshold);
  265. int mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core,
  266. unsigned int sb_index);
  267. int mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core,
  268. unsigned int sb_index);
  269. int mlxsw_sp_sb_occ_port_pool_get(struct mlxsw_core_port *mlxsw_core_port,
  270. unsigned int sb_index, u16 pool_index,
  271. u32 *p_cur, u32 *p_max);
  272. int mlxsw_sp_sb_occ_tc_port_bind_get(struct mlxsw_core_port *mlxsw_core_port,
  273. unsigned int sb_index, u16 tc_index,
  274. enum devlink_sb_pool_type pool_type,
  275. u32 *p_cur, u32 *p_max);
  276. u32 mlxsw_sp_cells_bytes(const struct mlxsw_sp *mlxsw_sp, u32 cells);
  277. u32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, u32 bytes);
  278. /* spectrum_switchdev.c */
  279. int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp);
  280. void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp);
  281. void mlxsw_sp_port_switchdev_init(struct mlxsw_sp_port *mlxsw_sp_port);
  282. void mlxsw_sp_port_switchdev_fini(struct mlxsw_sp_port *mlxsw_sp_port);
  283. int mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid,
  284. bool adding);
  285. void
  286. mlxsw_sp_port_vlan_bridge_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
  287. int mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port,
  288. struct net_device *brport_dev,
  289. struct net_device *br_dev);
  290. void mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port,
  291. struct net_device *brport_dev,
  292. struct net_device *br_dev);
  293. /* spectrum.c */
  294. int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port,
  295. enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index,
  296. bool dwrr, u8 dwrr_weight);
  297. int mlxsw_sp_port_prio_tc_set(struct mlxsw_sp_port *mlxsw_sp_port,
  298. u8 switch_prio, u8 tclass);
  299. int __mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port, int mtu,
  300. u8 *prio_tc, bool pause_en,
  301. struct ieee_pfc *my_pfc);
  302. int mlxsw_sp_port_ets_maxrate_set(struct mlxsw_sp_port *mlxsw_sp_port,
  303. enum mlxsw_reg_qeec_hr hr, u8 index,
  304. u8 next_index, u32 maxrate);
  305. int mlxsw_sp_port_vid_stp_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
  306. u8 state);
  307. int mlxsw_sp_port_vp_mode_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable);
  308. int mlxsw_sp_port_vid_learning_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
  309. bool learn_enable);
  310. int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
  311. struct mlxsw_sp_port_vlan *
  312. mlxsw_sp_port_vlan_get(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
  313. void mlxsw_sp_port_vlan_put(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
  314. int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin,
  315. u16 vid_end, bool is_member, bool untagged);
  316. int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp,
  317. unsigned int counter_index, u64 *packets,
  318. u64 *bytes);
  319. int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp,
  320. unsigned int *p_counter_index);
  321. void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp,
  322. unsigned int counter_index);
  323. bool mlxsw_sp_port_dev_check(const struct net_device *dev);
  324. struct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev);
  325. struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev);
  326. struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold(struct net_device *dev);
  327. void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port);
  328. struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu(struct net_device *dev);
  329. /* spectrum_dcb.c */
  330. #ifdef CONFIG_MLXSW_SPECTRUM_DCB
  331. int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port);
  332. void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port);
  333. #else
  334. static inline int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port)
  335. {
  336. return 0;
  337. }
  338. static inline void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port)
  339. {}
  340. #endif
  341. /* spectrum_router.c */
  342. int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp);
  343. void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp);
  344. int mlxsw_sp_router_netevent_event(struct notifier_block *unused,
  345. unsigned long event, void *ptr);
  346. int mlxsw_sp_netdevice_router_port_event(struct net_device *dev);
  347. int mlxsw_sp_inetaddr_event(struct notifier_block *unused,
  348. unsigned long event, void *ptr);
  349. int mlxsw_sp_inet6addr_event(struct notifier_block *unused,
  350. unsigned long event, void *ptr);
  351. int mlxsw_sp_netdevice_vrf_event(struct net_device *l3_dev, unsigned long event,
  352. struct netdev_notifier_changeupper_info *info);
  353. void
  354. mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
  355. void mlxsw_sp_rif_destroy(struct mlxsw_sp_rif *rif);
  356. /* spectrum_kvdl.c */
  357. int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count,
  358. u32 *p_entry_index);
  359. void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp, int entry_index);
  360. struct mlxsw_sp_acl_rule_info {
  361. unsigned int priority;
  362. struct mlxsw_afk_element_values values;
  363. struct mlxsw_afa_block *act_block;
  364. unsigned int counter_index;
  365. bool counter_valid;
  366. };
  367. enum mlxsw_sp_acl_profile {
  368. MLXSW_SP_ACL_PROFILE_FLOWER,
  369. };
  370. struct mlxsw_sp_acl_profile_ops {
  371. size_t ruleset_priv_size;
  372. int (*ruleset_add)(struct mlxsw_sp *mlxsw_sp,
  373. void *priv, void *ruleset_priv);
  374. void (*ruleset_del)(struct mlxsw_sp *mlxsw_sp, void *ruleset_priv);
  375. int (*ruleset_bind)(struct mlxsw_sp *mlxsw_sp, void *ruleset_priv,
  376. struct net_device *dev, bool ingress);
  377. void (*ruleset_unbind)(struct mlxsw_sp *mlxsw_sp, void *ruleset_priv);
  378. u16 (*ruleset_group_id)(void *ruleset_priv);
  379. size_t rule_priv_size;
  380. int (*rule_add)(struct mlxsw_sp *mlxsw_sp,
  381. void *ruleset_priv, void *rule_priv,
  382. struct mlxsw_sp_acl_rule_info *rulei);
  383. void (*rule_del)(struct mlxsw_sp *mlxsw_sp, void *rule_priv);
  384. int (*rule_activity_get)(struct mlxsw_sp *mlxsw_sp, void *rule_priv,
  385. bool *activity);
  386. };
  387. struct mlxsw_sp_acl_ops {
  388. size_t priv_size;
  389. int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv);
  390. void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv);
  391. const struct mlxsw_sp_acl_profile_ops *
  392. (*profile_ops)(struct mlxsw_sp *mlxsw_sp,
  393. enum mlxsw_sp_acl_profile profile);
  394. };
  395. struct mlxsw_sp_acl_ruleset;
  396. /* spectrum_acl.c */
  397. struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl);
  398. struct mlxsw_sp_acl_ruleset *
  399. mlxsw_sp_acl_ruleset_lookup(struct mlxsw_sp *mlxsw_sp, struct net_device *dev,
  400. bool ingress, u32 chain_index,
  401. enum mlxsw_sp_acl_profile profile);
  402. struct mlxsw_sp_acl_ruleset *
  403. mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp, struct net_device *dev,
  404. bool ingress, u32 chain_index,
  405. enum mlxsw_sp_acl_profile profile);
  406. void mlxsw_sp_acl_ruleset_put(struct mlxsw_sp *mlxsw_sp,
  407. struct mlxsw_sp_acl_ruleset *ruleset);
  408. u16 mlxsw_sp_acl_ruleset_group_id(struct mlxsw_sp_acl_ruleset *ruleset);
  409. struct mlxsw_sp_acl_rule_info *
  410. mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl);
  411. void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp_acl_rule_info *rulei);
  412. int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei);
  413. void mlxsw_sp_acl_rulei_priority(struct mlxsw_sp_acl_rule_info *rulei,
  414. unsigned int priority);
  415. void mlxsw_sp_acl_rulei_keymask_u32(struct mlxsw_sp_acl_rule_info *rulei,
  416. enum mlxsw_afk_element element,
  417. u32 key_value, u32 mask_value);
  418. void mlxsw_sp_acl_rulei_keymask_buf(struct mlxsw_sp_acl_rule_info *rulei,
  419. enum mlxsw_afk_element element,
  420. const char *key_value,
  421. const char *mask_value, unsigned int len);
  422. void mlxsw_sp_acl_rulei_act_continue(struct mlxsw_sp_acl_rule_info *rulei);
  423. void mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei,
  424. u16 group_id);
  425. int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei);
  426. int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei);
  427. int mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp *mlxsw_sp,
  428. struct mlxsw_sp_acl_rule_info *rulei,
  429. struct net_device *out_dev);
  430. int mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp *mlxsw_sp,
  431. struct mlxsw_sp_acl_rule_info *rulei,
  432. u32 action, u16 vid, u16 proto, u8 prio);
  433. int mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp *mlxsw_sp,
  434. struct mlxsw_sp_acl_rule_info *rulei);
  435. int mlxsw_sp_acl_rulei_act_fid_set(struct mlxsw_sp *mlxsw_sp,
  436. struct mlxsw_sp_acl_rule_info *rulei,
  437. u16 fid);
  438. struct mlxsw_sp_acl_rule;
  439. struct mlxsw_sp_acl_rule *
  440. mlxsw_sp_acl_rule_create(struct mlxsw_sp *mlxsw_sp,
  441. struct mlxsw_sp_acl_ruleset *ruleset,
  442. unsigned long cookie);
  443. void mlxsw_sp_acl_rule_destroy(struct mlxsw_sp *mlxsw_sp,
  444. struct mlxsw_sp_acl_rule *rule);
  445. int mlxsw_sp_acl_rule_add(struct mlxsw_sp *mlxsw_sp,
  446. struct mlxsw_sp_acl_rule *rule);
  447. void mlxsw_sp_acl_rule_del(struct mlxsw_sp *mlxsw_sp,
  448. struct mlxsw_sp_acl_rule *rule);
  449. struct mlxsw_sp_acl_rule *
  450. mlxsw_sp_acl_rule_lookup(struct mlxsw_sp *mlxsw_sp,
  451. struct mlxsw_sp_acl_ruleset *ruleset,
  452. unsigned long cookie);
  453. struct mlxsw_sp_acl_rule_info *
  454. mlxsw_sp_acl_rule_rulei(struct mlxsw_sp_acl_rule *rule);
  455. int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp,
  456. struct mlxsw_sp_acl_rule *rule,
  457. u64 *packets, u64 *bytes, u64 *last_use);
  458. struct mlxsw_sp_fid *mlxsw_sp_acl_dummy_fid(struct mlxsw_sp *mlxsw_sp);
  459. int mlxsw_sp_acl_init(struct mlxsw_sp *mlxsw_sp);
  460. void mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp);
  461. /* spectrum_acl_tcam.c */
  462. extern const struct mlxsw_sp_acl_ops mlxsw_sp_acl_tcam_ops;
  463. /* spectrum_flower.c */
  464. int mlxsw_sp_flower_replace(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress,
  465. struct tc_cls_flower_offload *f);
  466. void mlxsw_sp_flower_destroy(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress,
  467. struct tc_cls_flower_offload *f);
  468. int mlxsw_sp_flower_stats(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress,
  469. struct tc_cls_flower_offload *f);
  470. /* spectrum_fid.c */
  471. int mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid *fid,
  472. enum mlxsw_sp_flood_type packet_type, u8 local_port,
  473. bool member);
  474. int mlxsw_sp_fid_port_vid_map(struct mlxsw_sp_fid *fid,
  475. struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
  476. void mlxsw_sp_fid_port_vid_unmap(struct mlxsw_sp_fid *fid,
  477. struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
  478. enum mlxsw_sp_rif_type mlxsw_sp_fid_rif_type(const struct mlxsw_sp_fid *fid);
  479. u16 mlxsw_sp_fid_index(const struct mlxsw_sp_fid *fid);
  480. enum mlxsw_sp_fid_type mlxsw_sp_fid_type(const struct mlxsw_sp_fid *fid);
  481. void mlxsw_sp_fid_rif_set(struct mlxsw_sp_fid *fid, struct mlxsw_sp_rif *rif);
  482. enum mlxsw_sp_rif_type
  483. mlxsw_sp_fid_type_rif_type(const struct mlxsw_sp *mlxsw_sp,
  484. enum mlxsw_sp_fid_type type);
  485. u16 mlxsw_sp_fid_8021q_vid(const struct mlxsw_sp_fid *fid);
  486. struct mlxsw_sp_fid *mlxsw_sp_fid_8021q_get(struct mlxsw_sp *mlxsw_sp, u16 vid);
  487. struct mlxsw_sp_fid *mlxsw_sp_fid_8021d_get(struct mlxsw_sp *mlxsw_sp,
  488. int br_ifindex);
  489. struct mlxsw_sp_fid *mlxsw_sp_fid_rfid_get(struct mlxsw_sp *mlxsw_sp,
  490. u16 rif_index);
  491. struct mlxsw_sp_fid *mlxsw_sp_fid_dummy_get(struct mlxsw_sp *mlxsw_sp);
  492. void mlxsw_sp_fid_put(struct mlxsw_sp_fid *fid);
  493. int mlxsw_sp_port_fids_init(struct mlxsw_sp_port *mlxsw_sp_port);
  494. void mlxsw_sp_port_fids_fini(struct mlxsw_sp_port *mlxsw_sp_port);
  495. int mlxsw_sp_fids_init(struct mlxsw_sp *mlxsw_sp);
  496. void mlxsw_sp_fids_fini(struct mlxsw_sp *mlxsw_sp);
  497. #endif