mlxsw: Split handling of FDB tunnel entries between address families
Currently, the function which adds/removes unicast tunnel FDB entries is shared between IPv4 and IPv6, while for IPv6 it warns because there is no support for it. The code for IPv6 will be more complicated because it needs to allocate/release a KVDL pointer for the underlay IPv6 address. As a preparation for IPv6 underlay support, split the code according to address family. Signed-off-by: Amit Cohen <amcohen@nvidia.com> Signed-off-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
720d683cbe
commit
1fd85416e3
@ -504,19 +504,30 @@ static inline void
|
|||||||
mlxsw_reg_sfd_uc_tunnel_pack(char *payload, int rec_index,
|
mlxsw_reg_sfd_uc_tunnel_pack(char *payload, int rec_index,
|
||||||
enum mlxsw_reg_sfd_rec_policy policy,
|
enum mlxsw_reg_sfd_rec_policy policy,
|
||||||
const char *mac, u16 fid,
|
const char *mac, u16 fid,
|
||||||
enum mlxsw_reg_sfd_rec_action action, u32 uip,
|
enum mlxsw_reg_sfd_rec_action action,
|
||||||
enum mlxsw_reg_sfd_uc_tunnel_protocol proto)
|
enum mlxsw_reg_sfd_uc_tunnel_protocol proto)
|
||||||
{
|
{
|
||||||
mlxsw_reg_sfd_rec_pack(payload, rec_index,
|
mlxsw_reg_sfd_rec_pack(payload, rec_index,
|
||||||
MLXSW_REG_SFD_REC_TYPE_UNICAST_TUNNEL, mac,
|
MLXSW_REG_SFD_REC_TYPE_UNICAST_TUNNEL, mac,
|
||||||
action);
|
action);
|
||||||
mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
|
mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
|
||||||
mlxsw_reg_sfd_uc_tunnel_uip_msb_set(payload, rec_index, uip >> 24);
|
|
||||||
mlxsw_reg_sfd_uc_tunnel_uip_lsb_set(payload, rec_index, uip);
|
|
||||||
mlxsw_reg_sfd_uc_tunnel_fid_set(payload, rec_index, fid);
|
mlxsw_reg_sfd_uc_tunnel_fid_set(payload, rec_index, fid);
|
||||||
mlxsw_reg_sfd_uc_tunnel_protocol_set(payload, rec_index, proto);
|
mlxsw_reg_sfd_uc_tunnel_protocol_set(payload, rec_index, proto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
mlxsw_reg_sfd_uc_tunnel_pack4(char *payload, int rec_index,
|
||||||
|
enum mlxsw_reg_sfd_rec_policy policy,
|
||||||
|
const char *mac, u16 fid,
|
||||||
|
enum mlxsw_reg_sfd_rec_action action, u32 uip)
|
||||||
|
{
|
||||||
|
mlxsw_reg_sfd_uc_tunnel_uip_msb_set(payload, rec_index, uip >> 24);
|
||||||
|
mlxsw_reg_sfd_uc_tunnel_uip_lsb_set(payload, rec_index, uip);
|
||||||
|
mlxsw_reg_sfd_uc_tunnel_pack(payload, rec_index, policy, mac, fid,
|
||||||
|
action,
|
||||||
|
MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV4);
|
||||||
|
}
|
||||||
|
|
||||||
enum mlxsw_reg_tunnel_port {
|
enum mlxsw_reg_tunnel_port {
|
||||||
MLXSW_REG_TUNNEL_PORT_NVE,
|
MLXSW_REG_TUNNEL_PORT_NVE,
|
||||||
MLXSW_REG_TUNNEL_PORT_VPLS,
|
MLXSW_REG_TUNNEL_PORT_VPLS,
|
||||||
|
@ -1290,38 +1290,24 @@ static enum mlxsw_reg_sfd_op mlxsw_sp_sfd_op(bool adding)
|
|||||||
MLXSW_REG_SFD_OP_WRITE_REMOVE;
|
MLXSW_REG_SFD_OP_WRITE_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mlxsw_sp_port_fdb_tunnel_uc_op(struct mlxsw_sp *mlxsw_sp,
|
static int
|
||||||
const char *mac, u16 fid,
|
mlxsw_sp_port_fdb_tun_uc_op4(struct mlxsw_sp *mlxsw_sp, bool dynamic,
|
||||||
enum mlxsw_sp_l3proto proto,
|
const char *mac, u16 fid, __be32 addr, bool adding)
|
||||||
const union mlxsw_sp_l3addr *addr,
|
|
||||||
bool adding, bool dynamic)
|
|
||||||
{
|
{
|
||||||
enum mlxsw_reg_sfd_uc_tunnel_protocol sfd_proto;
|
|
||||||
char *sfd_pl;
|
char *sfd_pl;
|
||||||
u8 num_rec;
|
u8 num_rec;
|
||||||
u32 uip;
|
u32 uip;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
switch (proto) {
|
|
||||||
case MLXSW_SP_L3_PROTO_IPV4:
|
|
||||||
uip = be32_to_cpu(addr->addr4);
|
|
||||||
sfd_proto = MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV4;
|
|
||||||
break;
|
|
||||||
case MLXSW_SP_L3_PROTO_IPV6:
|
|
||||||
default:
|
|
||||||
WARN_ON(1);
|
|
||||||
return -EOPNOTSUPP;
|
|
||||||
}
|
|
||||||
|
|
||||||
sfd_pl = kmalloc(MLXSW_REG_SFD_LEN, GFP_KERNEL);
|
sfd_pl = kmalloc(MLXSW_REG_SFD_LEN, GFP_KERNEL);
|
||||||
if (!sfd_pl)
|
if (!sfd_pl)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
uip = be32_to_cpu(addr);
|
||||||
mlxsw_reg_sfd_pack(sfd_pl, mlxsw_sp_sfd_op(adding), 0);
|
mlxsw_reg_sfd_pack(sfd_pl, mlxsw_sp_sfd_op(adding), 0);
|
||||||
mlxsw_reg_sfd_uc_tunnel_pack(sfd_pl, 0,
|
mlxsw_reg_sfd_uc_tunnel_pack4(sfd_pl, 0,
|
||||||
mlxsw_sp_sfd_rec_policy(dynamic), mac, fid,
|
mlxsw_sp_sfd_rec_policy(dynamic), mac,
|
||||||
MLXSW_REG_SFD_REC_ACTION_NOP, uip,
|
fid, MLXSW_REG_SFD_REC_ACTION_NOP, uip);
|
||||||
sfd_proto);
|
|
||||||
num_rec = mlxsw_reg_sfd_num_rec_get(sfd_pl);
|
num_rec = mlxsw_reg_sfd_num_rec_get(sfd_pl);
|
||||||
err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sfd), sfd_pl);
|
err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sfd), sfd_pl);
|
||||||
if (err)
|
if (err)
|
||||||
@ -1335,6 +1321,23 @@ out:
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int mlxsw_sp_port_fdb_tunnel_uc_op(struct mlxsw_sp *mlxsw_sp,
|
||||||
|
const char *mac, u16 fid,
|
||||||
|
enum mlxsw_sp_l3proto proto,
|
||||||
|
const union mlxsw_sp_l3addr *addr,
|
||||||
|
bool adding, bool dynamic)
|
||||||
|
{
|
||||||
|
switch (proto) {
|
||||||
|
case MLXSW_SP_L3_PROTO_IPV4:
|
||||||
|
return mlxsw_sp_port_fdb_tun_uc_op4(mlxsw_sp, dynamic, mac, fid,
|
||||||
|
addr->addr4, adding);
|
||||||
|
case MLXSW_SP_L3_PROTO_IPV6:
|
||||||
|
default:
|
||||||
|
WARN_ON(1);
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int __mlxsw_sp_port_fdb_uc_op(struct mlxsw_sp *mlxsw_sp, u16 local_port,
|
static int __mlxsw_sp_port_fdb_uc_op(struct mlxsw_sp *mlxsw_sp, u16 local_port,
|
||||||
const char *mac, u16 fid, bool adding,
|
const char *mac, u16 fid, bool adding,
|
||||||
enum mlxsw_reg_sfd_rec_action action,
|
enum mlxsw_reg_sfd_rec_action action,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user