net/ixgbe: support VF MAC address add/remove
[dpdk.git] / drivers / net / iavf / base / iavf_lan_hmc.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2013 - 2015 Intel Corporation
3  */
4
5 #ifndef _IAVF_LAN_HMC_H_
6 #define _IAVF_LAN_HMC_H_
7
8 /* forward-declare the HW struct for the compiler */
9 struct iavf_hw;
10
11 /* HMC element context information */
12
13 /* Rx queue context data
14  *
15  * The sizes of the variables may be larger than needed due to crossing byte
16  * boundaries. If we do not have the width of the variable set to the correct
17  * size then we could end up shifting bits off the top of the variable when the
18  * variable is at the top of a byte and crosses over into the next byte.
19  */
20 struct iavf_hmc_obj_rxq {
21         u16 head;
22         u16 cpuid; /* bigger than needed, see above for reason */
23         u64 base;
24         u16 qlen;
25 #define IAVF_RXQ_CTX_DBUFF_SHIFT 7
26         u16 dbuff; /* bigger than needed, see above for reason */
27 #define IAVF_RXQ_CTX_HBUFF_SHIFT 6
28         u16 hbuff; /* bigger than needed, see above for reason */
29         u8  dtype;
30         u8  dsize;
31         u8  crcstrip;
32         u8  fc_ena;
33         u8  l2tsel;
34         u8  hsplit_0;
35         u8  hsplit_1;
36         u8  showiv;
37         u32 rxmax; /* bigger than needed, see above for reason */
38         u8  tphrdesc_ena;
39         u8  tphwdesc_ena;
40         u8  tphdata_ena;
41         u8  tphhead_ena;
42         u16 lrxqthresh; /* bigger than needed, see above for reason */
43         u8  prefena;    /* NOTE: normally must be set to 1 at init */
44 };
45
46 /* Tx queue context data
47 *
48 * The sizes of the variables may be larger than needed due to crossing byte
49 * boundaries. If we do not have the width of the variable set to the correct
50 * size then we could end up shifting bits off the top of the variable when the
51 * variable is at the top of a byte and crosses over into the next byte.
52 */
53 struct iavf_hmc_obj_txq {
54         u16 head;
55         u8  new_context;
56         u64 base;
57         u8  fc_ena;
58         u8  timesync_ena;
59         u8  fd_ena;
60         u8  alt_vlan_ena;
61         u16 thead_wb;
62         u8  cpuid;
63         u8  head_wb_ena;
64         u16 qlen;
65         u8  tphrdesc_ena;
66         u8  tphrpacket_ena;
67         u8  tphwdesc_ena;
68         u64 head_wb_addr;
69         u32 crc;
70         u16 rdylist;
71         u8  rdylist_act;
72 };
73
74 /* for hsplit_0 field of Rx HMC context */
75 enum iavf_hmc_obj_rx_hsplit_0 {
76         IAVF_HMC_OBJ_RX_HSPLIT_0_NO_SPLIT      = 0,
77         IAVF_HMC_OBJ_RX_HSPLIT_0_SPLIT_L2      = 1,
78         IAVF_HMC_OBJ_RX_HSPLIT_0_SPLIT_IP      = 2,
79         IAVF_HMC_OBJ_RX_HSPLIT_0_SPLIT_TCP_UDP = 4,
80         IAVF_HMC_OBJ_RX_HSPLIT_0_SPLIT_SCTP    = 8,
81 };
82
83 /* fcoe_cntx and fcoe_filt are for debugging purpose only */
84 struct iavf_hmc_obj_fcoe_cntx {
85         u32 rsv[32];
86 };
87
88 struct iavf_hmc_obj_fcoe_filt {
89         u32 rsv[8];
90 };
91
92 /* Context sizes for LAN objects */
93 enum iavf_hmc_lan_object_size {
94         IAVF_HMC_LAN_OBJ_SZ_8   = 0x3,
95         IAVF_HMC_LAN_OBJ_SZ_16  = 0x4,
96         IAVF_HMC_LAN_OBJ_SZ_32  = 0x5,
97         IAVF_HMC_LAN_OBJ_SZ_64  = 0x6,
98         IAVF_HMC_LAN_OBJ_SZ_128 = 0x7,
99         IAVF_HMC_LAN_OBJ_SZ_256 = 0x8,
100         IAVF_HMC_LAN_OBJ_SZ_512 = 0x9,
101 };
102
103 #define IAVF_HMC_L2OBJ_BASE_ALIGNMENT 512
104 #define IAVF_HMC_OBJ_SIZE_TXQ         128
105 #define IAVF_HMC_OBJ_SIZE_RXQ         32
106 #define IAVF_HMC_OBJ_SIZE_FCOE_CNTX   64
107 #define IAVF_HMC_OBJ_SIZE_FCOE_FILT   64
108
109 enum iavf_hmc_lan_rsrc_type {
110         IAVF_HMC_LAN_FULL  = 0,
111         IAVF_HMC_LAN_TX    = 1,
112         IAVF_HMC_LAN_RX    = 2,
113         IAVF_HMC_FCOE_CTX  = 3,
114         IAVF_HMC_FCOE_FILT = 4,
115         IAVF_HMC_LAN_MAX   = 5
116 };
117
118 enum iavf_hmc_model {
119         IAVF_HMC_MODEL_DIRECT_PREFERRED = 0,
120         IAVF_HMC_MODEL_DIRECT_ONLY      = 1,
121         IAVF_HMC_MODEL_PAGED_ONLY       = 2,
122         IAVF_HMC_MODEL_UNKNOWN,
123 };
124
125 struct iavf_hmc_lan_create_obj_info {
126         struct iavf_hmc_info *hmc_info;
127         u32 rsrc_type;
128         u32 start_idx;
129         u32 count;
130         enum iavf_sd_entry_type entry_type;
131         u64 direct_mode_sz;
132 };
133
134 struct iavf_hmc_lan_delete_obj_info {
135         struct iavf_hmc_info *hmc_info;
136         u32 rsrc_type;
137         u32 start_idx;
138         u32 count;
139 };
140
141 enum iavf_status_code iavf_init_lan_hmc(struct iavf_hw *hw, u32 txq_num,
142                                         u32 rxq_num, u32 fcoe_cntx_num,
143                                         u32 fcoe_filt_num);
144 enum iavf_status_code iavf_configure_lan_hmc(struct iavf_hw *hw,
145                                              enum iavf_hmc_model model);
146 enum iavf_status_code iavf_shutdown_lan_hmc(struct iavf_hw *hw);
147
148 u64 iavf_calculate_l2fpm_size(u32 txq_num, u32 rxq_num,
149                               u32 fcoe_cntx_num, u32 fcoe_filt_num);
150 enum iavf_status_code iavf_get_lan_tx_queue_context(struct iavf_hw *hw,
151                                                     u16 queue,
152                                                     struct iavf_hmc_obj_txq *s);
153 enum iavf_status_code iavf_clear_lan_tx_queue_context(struct iavf_hw *hw,
154                                                       u16 queue);
155 enum iavf_status_code iavf_set_lan_tx_queue_context(struct iavf_hw *hw,
156                                                     u16 queue,
157                                                     struct iavf_hmc_obj_txq *s);
158 enum iavf_status_code iavf_get_lan_rx_queue_context(struct iavf_hw *hw,
159                                                     u16 queue,
160                                                     struct iavf_hmc_obj_rxq *s);
161 enum iavf_status_code iavf_clear_lan_rx_queue_context(struct iavf_hw *hw,
162                                                       u16 queue);
163 enum iavf_status_code iavf_set_lan_rx_queue_context(struct iavf_hw *hw,
164                                                     u16 queue,
165                                                     struct iavf_hmc_obj_rxq *s);
166 enum iavf_status_code iavf_create_lan_hmc_object(struct iavf_hw *hw,
167                                 struct iavf_hmc_lan_create_obj_info *info);
168 enum iavf_status_code iavf_delete_lan_hmc_object(struct iavf_hw *hw,
169                                 struct iavf_hmc_lan_delete_obj_info *info);
170
171 #endif /* _IAVF_LAN_HMC_H_ */