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