Merge tag 'm68k-for-v4.19-tag2' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-block.git] / drivers / net / ethernet / intel / ice / ice_switch.h
CommitLineData
9c20346b
AV
1/* SPDX-License-Identifier: GPL-2.0 */
2/* Copyright (c) 2018, Intel Corporation. */
3
4#ifndef _ICE_SWITCH_H_
5#define _ICE_SWITCH_H_
6
7#include "ice_common.h"
8
9#define ICE_SW_CFG_MAX_BUF_LEN 2048
10#define ICE_DFLT_VSI_INVAL 0xff
d76a60ba 11#define ICE_VSI_INVAL_ID 0xffff
9c20346b 12
3a858ba3
AV
13/* VSI context structure for add/get/update/free operations */
14struct ice_vsi_ctx {
15 u16 vsi_num;
16 u16 vsis_allocd;
17 u16 vsis_unallocated;
18 u16 flags;
19 struct ice_aqc_vsi_props info;
43f8b224 20 u8 alloc_from_pool;
3a858ba3
AV
21};
22
9daf8208
AV
23enum ice_sw_fwd_act_type {
24 ICE_FWD_TO_VSI = 0,
25 ICE_FWD_TO_VSI_LIST, /* Do not use this when adding filter */
26 ICE_FWD_TO_Q,
27 ICE_FWD_TO_QGRP,
28 ICE_DROP_PACKET,
29 ICE_INVAL_ACT
30};
31
32/* Switch recipe ID enum values are specific to hardware */
33enum ice_sw_lkup_type {
34 ICE_SW_LKUP_ETHERTYPE = 0,
35 ICE_SW_LKUP_MAC = 1,
36 ICE_SW_LKUP_MAC_VLAN = 2,
37 ICE_SW_LKUP_PROMISC = 3,
38 ICE_SW_LKUP_VLAN = 4,
39 ICE_SW_LKUP_DFLT = 5,
40 ICE_SW_LKUP_ETHERTYPE_MAC = 8,
41 ICE_SW_LKUP_PROMISC_VLAN = 9,
42};
43
44struct ice_fltr_info {
45 /* Look up information: how to look up packet */
46 enum ice_sw_lkup_type lkup_type;
47 /* Forward action: filter action to do after lookup */
48 enum ice_sw_fwd_act_type fltr_act;
49 /* rule ID returned by firmware once filter rule is created */
50 u16 fltr_rule_id;
51 u16 flag;
52#define ICE_FLTR_RX BIT(0)
53#define ICE_FLTR_TX BIT(1)
54#define ICE_FLTR_TX_RX (ICE_FLTR_RX | ICE_FLTR_TX)
55
56 /* Source VSI for LOOKUP_TX or source port for LOOKUP_RX */
57 u16 src;
58
59 union {
60 struct {
61 u8 mac_addr[ETH_ALEN];
62 } mac;
63 struct {
64 u8 mac_addr[ETH_ALEN];
65 u16 vlan_id;
66 } mac_vlan;
67 struct {
68 u16 vlan_id;
69 } vlan;
70 /* Set lkup_type as ICE_SW_LKUP_ETHERTYPE
71 * if just using ethertype as filter. Set lkup_type as
72 * ICE_SW_LKUP_ETHERTYPE_MAC if MAC also needs to be
73 * passed in as filter.
74 */
75 struct {
76 u16 ethertype;
77 u8 mac_addr[ETH_ALEN]; /* optional */
78 } ethertype_mac;
79 } l_data;
80
81 /* Depending on filter action */
82 union {
83 /* queue id in case of ICE_FWD_TO_Q and starting
84 * queue id in case of ICE_FWD_TO_QGRP.
85 */
86 u16 q_id:11;
87 u16 vsi_id:10;
88 u16 vsi_list_id:10;
89 } fwd_id;
90
91 /* Set to num_queues if action is ICE_FWD_TO_QGRP. This field
92 * determines the range of queues the packet needs to be forwarded to
93 */
94 u8 qgrp_size;
95
96 /* Rule creations populate these indicators basing on the switch type */
43f8b224
BA
97 u8 lb_en; /* Indicate if packet can be looped back */
98 u8 lan_en; /* Indicate if packet can be forwarded to the uplink */
9daf8208
AV
99};
100
101/* Bookkeeping structure to hold bitmap of VSIs corresponding to VSI list id */
102struct ice_vsi_list_map_info {
103 struct list_head list_entry;
104 DECLARE_BITMAP(vsi_map, ICE_MAX_VSI);
105 u16 vsi_list_id;
106};
107
108enum ice_sw_fltr_status {
109 ICE_FLTR_STATUS_NEW = 0,
110 ICE_FLTR_STATUS_FW_SUCCESS,
111 ICE_FLTR_STATUS_FW_FAIL,
112};
113
114struct ice_fltr_list_entry {
115 struct list_head list_entry;
116 enum ice_sw_fltr_status status;
117 struct ice_fltr_info fltr_info;
118};
119
120/* This defines an entry in the list that maintains MAC or VLAN membership
121 * to HW list mapping, since multiple VSIs can subscribe to the same MAC or
122 * VLAN. As an optimization the VSI list should be created only when a
123 * second VSI becomes a subscriber to the VLAN address.
124 */
125struct ice_fltr_mgmt_list_entry {
126 /* back pointer to VSI list id to VSI list mapping */
127 struct ice_vsi_list_map_info *vsi_list_info;
128 u16 vsi_count;
129#define ICE_INVAL_LG_ACT_INDEX 0xffff
130 u16 lg_act_idx;
131#define ICE_INVAL_SW_MARKER_ID 0xffff
132 u16 sw_marker_id;
133 struct list_head list_entry;
134 struct ice_fltr_info fltr_info;
135#define ICE_INVAL_COUNTER_ID 0xff
136 u8 counter_index;
137};
138
3a858ba3
AV
139/* VSI related commands */
140enum ice_status
141ice_aq_add_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
142 struct ice_sq_cd *cd);
143enum ice_status
144ice_aq_update_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
145 struct ice_sq_cd *cd);
146enum ice_status
147ice_aq_free_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
148 bool keep_vsi_alloc, struct ice_sq_cd *cd);
149
9c20346b
AV
150enum ice_status ice_get_initial_sw_cfg(struct ice_hw *hw);
151
9daf8208
AV
152/* Switch/bridge related commands */
153enum ice_status ice_add_mac(struct ice_hw *hw, struct list_head *m_lst);
154enum ice_status ice_remove_mac(struct ice_hw *hw, struct list_head *m_lst);
155void ice_remove_vsi_fltr(struct ice_hw *hw, u16 vsi_id);
d76a60ba
AV
156enum ice_status ice_add_vlan(struct ice_hw *hw, struct list_head *m_list);
157enum ice_status ice_remove_vlan(struct ice_hw *hw, struct list_head *v_list);
e94d4478
AV
158enum ice_status
159ice_cfg_dflt_vsi(struct ice_hw *hw, u16 vsi_id, bool set, u8 direction);
d76a60ba 160
9c20346b 161#endif /* _ICE_SWITCH_H_ */