Skip to content

Commit d82b731

Browse files
Saeed Mahameeddavem330
authored andcommitted
net/mlx5: Introduce access functions to modify/query vport promisc mode
Those functions are needed to notify the upcoming SR-IOV E-Switch(FDB) manager(PF), of the NIC vport (vf) promisc mode changes. Preperation for ethernet sriov and l2 table management. Signed-off-by: Saeed Mahameed <[email protected]> Signed-off-by: Or Gerlitz <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e754651 commit d82b731

File tree

3 files changed

+94
-5
lines changed

3 files changed

+94
-5
lines changed

drivers/net/ethernet/mellanox/mlx5/core/vport.c

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,3 +576,65 @@ int mlx5_query_hca_vport_node_guid(struct mlx5_core_dev *dev,
576576
return err;
577577
}
578578
EXPORT_SYMBOL_GPL(mlx5_query_hca_vport_node_guid);
579+
580+
int mlx5_query_nic_vport_promisc(struct mlx5_core_dev *mdev,
581+
u32 vport,
582+
int *promisc_uc,
583+
int *promisc_mc,
584+
int *promisc_all)
585+
{
586+
u32 *out;
587+
int outlen = MLX5_ST_SZ_BYTES(query_nic_vport_context_out);
588+
int err;
589+
590+
out = kzalloc(outlen, GFP_KERNEL);
591+
if (!out)
592+
return -ENOMEM;
593+
594+
err = mlx5_query_nic_vport_context(mdev, vport, out, outlen);
595+
if (err)
596+
goto out;
597+
598+
*promisc_uc = MLX5_GET(query_nic_vport_context_out, out,
599+
nic_vport_context.promisc_uc);
600+
*promisc_mc = MLX5_GET(query_nic_vport_context_out, out,
601+
nic_vport_context.promisc_mc);
602+
*promisc_all = MLX5_GET(query_nic_vport_context_out, out,
603+
nic_vport_context.promisc_all);
604+
605+
out:
606+
kfree(out);
607+
return err;
608+
}
609+
EXPORT_SYMBOL_GPL(mlx5_query_nic_vport_promisc);
610+
611+
int mlx5_modify_nic_vport_promisc(struct mlx5_core_dev *mdev,
612+
int promisc_uc,
613+
int promisc_mc,
614+
int promisc_all)
615+
{
616+
void *in;
617+
int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in);
618+
int err;
619+
620+
in = mlx5_vzalloc(inlen);
621+
if (!in) {
622+
mlx5_core_err(mdev, "failed to allocate inbox\n");
623+
return -ENOMEM;
624+
}
625+
626+
MLX5_SET(modify_nic_vport_context_in, in, field_select.promisc, 1);
627+
MLX5_SET(modify_nic_vport_context_in, in,
628+
nic_vport_context.promisc_uc, promisc_uc);
629+
MLX5_SET(modify_nic_vport_context_in, in,
630+
nic_vport_context.promisc_mc, promisc_mc);
631+
MLX5_SET(modify_nic_vport_context_in, in,
632+
nic_vport_context.promisc_all, promisc_all);
633+
634+
err = mlx5_modify_nic_vport_context(mdev, in, inlen);
635+
636+
kvfree(in);
637+
638+
return err;
639+
}
640+
EXPORT_SYMBOL_GPL(mlx5_modify_nic_vport_promisc);

include/linux/mlx5/mlx5_ifc.h

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,16 +2147,31 @@ struct mlx5_ifc_nic_vport_context_bits {
21472147
u8 reserved_0[0x1f];
21482148
u8 roce_en[0x1];
21492149

2150-
u8 reserved_1[0x760];
2150+
u8 arm_change_event[0x1];
2151+
u8 reserved_1[0x1a];
2152+
u8 event_on_mtu[0x1];
2153+
u8 event_on_promisc_change[0x1];
2154+
u8 event_on_vlan_change[0x1];
2155+
u8 event_on_mc_address_change[0x1];
2156+
u8 event_on_uc_address_change[0x1];
21512157

2152-
u8 reserved_2[0x5];
2158+
u8 reserved_2[0xf0];
2159+
2160+
u8 mtu[0x10];
2161+
2162+
u8 reserved_3[0x640];
2163+
2164+
u8 promisc_uc[0x1];
2165+
u8 promisc_mc[0x1];
2166+
u8 promisc_all[0x1];
2167+
u8 reserved_4[0x2];
21532168
u8 allowed_list_type[0x3];
2154-
u8 reserved_3[0xc];
2169+
u8 reserved_5[0xc];
21552170
u8 allowed_list_size[0xc];
21562171

21572172
struct mlx5_ifc_mac_address_layout_bits permanent_address;
21582173

2159-
u8 reserved_4[0x20];
2174+
u8 reserved_6[0x20];
21602175

21612176
u8 current_uc_mac_address[0][0x40];
21622177
};
@@ -4235,7 +4250,10 @@ struct mlx5_ifc_modify_nic_vport_context_out_bits {
42354250
};
42364251

42374252
struct mlx5_ifc_modify_nic_vport_field_select_bits {
4238-
u8 reserved_0[0x1c];
4253+
u8 reserved_0[0x19];
4254+
u8 mtu[0x1];
4255+
u8 change_event[0x1];
4256+
u8 promisc[0x1];
42394257
u8 permanent_address[0x1];
42404258
u8 addresses_list[0x1];
42414259
u8 roce_en[0x1];

include/linux/mlx5/vport.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,14 @@ int mlx5_modify_nic_vport_mac_list(struct mlx5_core_dev *dev,
6868
enum mlx5_list_type list_type,
6969
u8 addr_list[][ETH_ALEN],
7070
int list_size);
71+
int mlx5_query_nic_vport_promisc(struct mlx5_core_dev *mdev,
72+
u32 vport,
73+
int *promisc_uc,
74+
int *promisc_mc,
75+
int *promisc_all);
76+
int mlx5_modify_nic_vport_promisc(struct mlx5_core_dev *mdev,
77+
int promisc_uc,
78+
int promisc_mc,
79+
int promisc_all);
7180

7281
#endif /* __MLX5_VPORT_H__ */

0 commit comments

Comments
 (0)