@@ -150,6 +150,125 @@ int mlx5_modify_nic_vport_mac_address(struct mlx5_core_dev *mdev,
150
150
}
151
151
EXPORT_SYMBOL (mlx5_modify_nic_vport_mac_address );
152
152
153
+ int mlx5_query_nic_vport_mac_list (struct mlx5_core_dev * dev ,
154
+ u32 vport ,
155
+ enum mlx5_list_type list_type ,
156
+ u8 addr_list [][ETH_ALEN ],
157
+ int * list_size )
158
+ {
159
+ u32 in [MLX5_ST_SZ_DW (query_nic_vport_context_in )];
160
+ void * nic_vport_ctx ;
161
+ int max_list_size ;
162
+ int req_list_size ;
163
+ int out_sz ;
164
+ void * out ;
165
+ int err ;
166
+ int i ;
167
+
168
+ req_list_size = * list_size ;
169
+
170
+ max_list_size = list_type == MLX5_NVPRT_LIST_TYPE_UC ?
171
+ 1 << MLX5_CAP_GEN (dev , log_max_current_uc_list ) :
172
+ 1 << MLX5_CAP_GEN (dev , log_max_current_mc_list );
173
+
174
+ if (req_list_size > max_list_size ) {
175
+ mlx5_core_warn (dev , "Requested list size (%d) > (%d) max_list_size\n" ,
176
+ req_list_size , max_list_size );
177
+ req_list_size = max_list_size ;
178
+ }
179
+
180
+ out_sz = MLX5_ST_SZ_BYTES (modify_nic_vport_context_in ) +
181
+ req_list_size * MLX5_ST_SZ_BYTES (mac_address_layout );
182
+
183
+ memset (in , 0 , sizeof (in ));
184
+ out = kzalloc (out_sz , GFP_KERNEL );
185
+ if (!out )
186
+ return - ENOMEM ;
187
+
188
+ MLX5_SET (query_nic_vport_context_in , in , opcode ,
189
+ MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT );
190
+ MLX5_SET (query_nic_vport_context_in , in , allowed_list_type , list_type );
191
+ MLX5_SET (query_nic_vport_context_in , in , vport_number , vport );
192
+
193
+ if (vport )
194
+ MLX5_SET (query_nic_vport_context_in , in , other_vport , 1 );
195
+
196
+ err = mlx5_cmd_exec_check_status (dev , in , sizeof (in ), out , out_sz );
197
+ if (err )
198
+ goto out ;
199
+
200
+ nic_vport_ctx = MLX5_ADDR_OF (query_nic_vport_context_out , out ,
201
+ nic_vport_context );
202
+ req_list_size = MLX5_GET (nic_vport_context , nic_vport_ctx ,
203
+ allowed_list_size );
204
+
205
+ * list_size = req_list_size ;
206
+ for (i = 0 ; i < req_list_size ; i ++ ) {
207
+ u8 * mac_addr = MLX5_ADDR_OF (nic_vport_context ,
208
+ nic_vport_ctx ,
209
+ current_uc_mac_address [i ]) + 2 ;
210
+ ether_addr_copy (addr_list [i ], mac_addr );
211
+ }
212
+ out :
213
+ kfree (out );
214
+ return err ;
215
+ }
216
+ EXPORT_SYMBOL_GPL (mlx5_query_nic_vport_mac_list );
217
+
218
+ int mlx5_modify_nic_vport_mac_list (struct mlx5_core_dev * dev ,
219
+ enum mlx5_list_type list_type ,
220
+ u8 addr_list [][ETH_ALEN ],
221
+ int list_size )
222
+ {
223
+ u32 out [MLX5_ST_SZ_DW (modify_nic_vport_context_out )];
224
+ void * nic_vport_ctx ;
225
+ int max_list_size ;
226
+ int in_sz ;
227
+ void * in ;
228
+ int err ;
229
+ int i ;
230
+
231
+ max_list_size = list_type == MLX5_NVPRT_LIST_TYPE_UC ?
232
+ 1 << MLX5_CAP_GEN (dev , log_max_current_uc_list ) :
233
+ 1 << MLX5_CAP_GEN (dev , log_max_current_mc_list );
234
+
235
+ if (list_size > max_list_size )
236
+ return - ENOSPC ;
237
+
238
+ in_sz = MLX5_ST_SZ_BYTES (modify_nic_vport_context_in ) +
239
+ list_size * MLX5_ST_SZ_BYTES (mac_address_layout );
240
+
241
+ memset (out , 0 , sizeof (out ));
242
+ in = kzalloc (in_sz , GFP_KERNEL );
243
+ if (!in )
244
+ return - ENOMEM ;
245
+
246
+ MLX5_SET (modify_nic_vport_context_in , in , opcode ,
247
+ MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT );
248
+ MLX5_SET (modify_nic_vport_context_in , in ,
249
+ field_select .addresses_list , 1 );
250
+
251
+ nic_vport_ctx = MLX5_ADDR_OF (modify_nic_vport_context_in , in ,
252
+ nic_vport_context );
253
+
254
+ MLX5_SET (nic_vport_context , nic_vport_ctx ,
255
+ allowed_list_type , list_type );
256
+ MLX5_SET (nic_vport_context , nic_vport_ctx ,
257
+ allowed_list_size , list_size );
258
+
259
+ for (i = 0 ; i < list_size ; i ++ ) {
260
+ u8 * curr_mac = MLX5_ADDR_OF (nic_vport_context ,
261
+ nic_vport_ctx ,
262
+ current_uc_mac_address [i ]) + 2 ;
263
+ ether_addr_copy (curr_mac , addr_list [i ]);
264
+ }
265
+
266
+ err = mlx5_cmd_exec_check_status (dev , in , in_sz , out , sizeof (out ));
267
+ kfree (in );
268
+ return err ;
269
+ }
270
+ EXPORT_SYMBOL_GPL (mlx5_modify_nic_vport_mac_list );
271
+
153
272
int mlx5_query_hca_vport_gid (struct mlx5_core_dev * dev , u8 other_vport ,
154
273
u8 port_num , u16 vf_num , u16 gid_index ,
155
274
union ib_gid * gid )
0 commit comments