mlxsw: core: Do not worry about changing 'enable_string_tlv' while sending EMADs
Till now, the field 'mlxsw_core->emad.enable_string_tlv' is set as part of mlxsw_sp_init(), this means that it can be changed during emad_reg_access(). To avoid such change, this field is read once in emad_reg_access() and the value is used all the way. The previous patch sets this value according to MGIR output, as part of mlxsw_emad_init(), so now it cannot be changed while sending EMADs. Do not save 'enable_string_tlv' and do not pass it to functions, just pass 'struct mlxsw_core' and use the value directly from it. Signed-off-by: Amit Cohen <amcohen@nvidia.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: Petr Machata <petrm@nvidia.com> Reviewed-by: Tony Nguyen <anthony.l.nguyen@intel.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
d84e2359e6
commit
563bd3c490
|
@ -476,11 +476,11 @@ static int mlxsw_emad_construct_eth_hdr(struct sk_buff *skb)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mlxsw_emad_construct(struct sk_buff *skb,
|
static void mlxsw_emad_construct(const struct mlxsw_core *mlxsw_core,
|
||||||
|
struct sk_buff *skb,
|
||||||
const struct mlxsw_reg_info *reg,
|
const struct mlxsw_reg_info *reg,
|
||||||
char *payload,
|
char *payload,
|
||||||
enum mlxsw_core_reg_access_type type,
|
enum mlxsw_core_reg_access_type type, u64 tid)
|
||||||
u64 tid, bool enable_string_tlv)
|
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
|
@ -490,7 +490,7 @@ static void mlxsw_emad_construct(struct sk_buff *skb,
|
||||||
buf = skb_push(skb, reg->len + sizeof(u32));
|
buf = skb_push(skb, reg->len + sizeof(u32));
|
||||||
mlxsw_emad_pack_reg_tlv(buf, reg, payload);
|
mlxsw_emad_pack_reg_tlv(buf, reg, payload);
|
||||||
|
|
||||||
if (enable_string_tlv) {
|
if (mlxsw_core->emad.enable_string_tlv) {
|
||||||
buf = skb_push(skb, MLXSW_EMAD_STRING_TLV_LEN * sizeof(u32));
|
buf = skb_push(skb, MLXSW_EMAD_STRING_TLV_LEN * sizeof(u32));
|
||||||
mlxsw_emad_pack_string_tlv(buf);
|
mlxsw_emad_pack_string_tlv(buf);
|
||||||
}
|
}
|
||||||
|
@ -876,7 +876,7 @@ static void mlxsw_emad_fini(struct mlxsw_core *mlxsw_core)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct sk_buff *mlxsw_emad_alloc(const struct mlxsw_core *mlxsw_core,
|
static struct sk_buff *mlxsw_emad_alloc(const struct mlxsw_core *mlxsw_core,
|
||||||
u16 reg_len, bool enable_string_tlv)
|
u16 reg_len)
|
||||||
{
|
{
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
u16 emad_len;
|
u16 emad_len;
|
||||||
|
@ -884,7 +884,7 @@ static struct sk_buff *mlxsw_emad_alloc(const struct mlxsw_core *mlxsw_core,
|
||||||
emad_len = (reg_len + sizeof(u32) + MLXSW_EMAD_ETH_HDR_LEN +
|
emad_len = (reg_len + sizeof(u32) + MLXSW_EMAD_ETH_HDR_LEN +
|
||||||
(MLXSW_EMAD_OP_TLV_LEN + MLXSW_EMAD_END_TLV_LEN) *
|
(MLXSW_EMAD_OP_TLV_LEN + MLXSW_EMAD_END_TLV_LEN) *
|
||||||
sizeof(u32) + mlxsw_core->driver->txhdr_len);
|
sizeof(u32) + mlxsw_core->driver->txhdr_len);
|
||||||
if (enable_string_tlv)
|
if (mlxsw_core->emad.enable_string_tlv)
|
||||||
emad_len += MLXSW_EMAD_STRING_TLV_LEN * sizeof(u32);
|
emad_len += MLXSW_EMAD_STRING_TLV_LEN * sizeof(u32);
|
||||||
if (emad_len > MLXSW_EMAD_MAX_FRAME_LEN)
|
if (emad_len > MLXSW_EMAD_MAX_FRAME_LEN)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -907,7 +907,6 @@ static int mlxsw_emad_reg_access(struct mlxsw_core *mlxsw_core,
|
||||||
mlxsw_reg_trans_cb_t *cb,
|
mlxsw_reg_trans_cb_t *cb,
|
||||||
unsigned long cb_priv, u64 tid)
|
unsigned long cb_priv, u64 tid)
|
||||||
{
|
{
|
||||||
bool enable_string_tlv;
|
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
@ -915,12 +914,7 @@ static int mlxsw_emad_reg_access(struct mlxsw_core *mlxsw_core,
|
||||||
tid, reg->id, mlxsw_reg_id_str(reg->id),
|
tid, reg->id, mlxsw_reg_id_str(reg->id),
|
||||||
mlxsw_core_reg_access_type_str(type));
|
mlxsw_core_reg_access_type_str(type));
|
||||||
|
|
||||||
/* Since this can be changed during emad_reg_access, read it once and
|
skb = mlxsw_emad_alloc(mlxsw_core, reg->len);
|
||||||
* use the value all the way.
|
|
||||||
*/
|
|
||||||
enable_string_tlv = mlxsw_core->emad.enable_string_tlv;
|
|
||||||
|
|
||||||
skb = mlxsw_emad_alloc(mlxsw_core, reg->len, enable_string_tlv);
|
|
||||||
if (!skb)
|
if (!skb)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -937,8 +931,7 @@ static int mlxsw_emad_reg_access(struct mlxsw_core *mlxsw_core,
|
||||||
trans->reg = reg;
|
trans->reg = reg;
|
||||||
trans->type = type;
|
trans->type = type;
|
||||||
|
|
||||||
mlxsw_emad_construct(skb, reg, payload, type, trans->tid,
|
mlxsw_emad_construct(mlxsw_core, skb, reg, payload, type, trans->tid);
|
||||||
enable_string_tlv);
|
|
||||||
mlxsw_core->driver->txhdr_construct(skb, &trans->tx_info);
|
mlxsw_core->driver->txhdr_construct(skb, &trans->tx_info);
|
||||||
|
|
||||||
spin_lock_bh(&mlxsw_core->emad.trans_list_lock);
|
spin_lock_bh(&mlxsw_core->emad.trans_list_lock);
|
||||||
|
|
Loading…
Reference in New Issue