Commit 511a5adc authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

mlxsw: spectrum_acl: Write RX_ACL_SYSTEM_PORT acl element correctly

RX_ACL_SYSTEM_PORT is equal to SRC_SYS_PORT - 1. So before write to
block we need to adjust the key value. Introduce new "EXT" helper to
implement this.
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9558a83a
...@@ -385,12 +385,12 @@ EXPORT_SYMBOL(mlxsw_afk_values_add_buf); ...@@ -385,12 +385,12 @@ EXPORT_SYMBOL(mlxsw_afk_values_add_buf);
static void mlxsw_sp_afk_encode_u32(const struct mlxsw_item *storage_item, static void mlxsw_sp_afk_encode_u32(const struct mlxsw_item *storage_item,
const struct mlxsw_item *output_item, const struct mlxsw_item *output_item,
char *storage, char *output) char *storage, char *output, int diff)
{ {
u32 value; u32 value;
value = __mlxsw_item_get32(storage, storage_item, 0); value = __mlxsw_item_get32(storage, storage_item, 0);
__mlxsw_item_set32(output, output_item, 0, value); __mlxsw_item_set32(output, output_item, 0, value + diff);
} }
static void mlxsw_sp_afk_encode_buf(const struct mlxsw_item *storage_item, static void mlxsw_sp_afk_encode_buf(const struct mlxsw_item *storage_item,
...@@ -406,14 +406,14 @@ static void mlxsw_sp_afk_encode_buf(const struct mlxsw_item *storage_item, ...@@ -406,14 +406,14 @@ static void mlxsw_sp_afk_encode_buf(const struct mlxsw_item *storage_item,
static void static void
mlxsw_sp_afk_encode_one(const struct mlxsw_afk_element_inst *elinst, mlxsw_sp_afk_encode_one(const struct mlxsw_afk_element_inst *elinst,
char *output, char *storage) char *output, char *storage, int u32_diff)
{ {
const struct mlxsw_item *storage_item = &elinst->info->item; const struct mlxsw_item *storage_item = &elinst->info->item;
const struct mlxsw_item *output_item = &elinst->item; const struct mlxsw_item *output_item = &elinst->item;
if (elinst->type == MLXSW_AFK_ELEMENT_TYPE_U32) if (elinst->type == MLXSW_AFK_ELEMENT_TYPE_U32)
mlxsw_sp_afk_encode_u32(storage_item, output_item, mlxsw_sp_afk_encode_u32(storage_item, output_item,
storage, output); storage, output, u32_diff);
else if (elinst->type == MLXSW_AFK_ELEMENT_TYPE_BUF) else if (elinst->type == MLXSW_AFK_ELEMENT_TYPE_BUF)
mlxsw_sp_afk_encode_buf(storage_item, output_item, mlxsw_sp_afk_encode_buf(storage_item, output_item,
storage, output); storage, output);
...@@ -446,9 +446,10 @@ void mlxsw_afk_encode(struct mlxsw_afk *mlxsw_afk, ...@@ -446,9 +446,10 @@ void mlxsw_afk_encode(struct mlxsw_afk *mlxsw_afk,
continue; continue;
mlxsw_sp_afk_encode_one(elinst, block_key, mlxsw_sp_afk_encode_one(elinst, block_key,
values->storage.key); values->storage.key,
elinst->u32_key_diff);
mlxsw_sp_afk_encode_one(elinst, block_mask, mlxsw_sp_afk_encode_one(elinst, block_mask,
values->storage.mask); values->storage.mask, 0);
} }
mlxsw_afk->ops->encode_block(key, i, block_key); mlxsw_afk->ops->encode_block(key, i, block_key);
......
...@@ -107,9 +107,13 @@ struct mlxsw_afk_element_inst { /* element instance in actual block */ ...@@ -107,9 +107,13 @@ struct mlxsw_afk_element_inst { /* element instance in actual block */
const struct mlxsw_afk_element_info *info; const struct mlxsw_afk_element_info *info;
enum mlxsw_afk_element_type type; enum mlxsw_afk_element_type type;
struct mlxsw_item item; /* element geometry in block */ struct mlxsw_item item; /* element geometry in block */
int u32_key_diff; /* in case value needs to be adjusted before write
* this diff is here to handle that
*/
}; };
#define MLXSW_AFK_ELEMENT_INST(_type, _element, _offset, _shift, _size) \ #define MLXSW_AFK_ELEMENT_INST(_type, _element, _offset, \
_shift, _size, _u32_key_diff) \
{ \ { \
.info = &mlxsw_afk_element_infos[MLXSW_AFK_ELEMENT_##_element], \ .info = &mlxsw_afk_element_infos[MLXSW_AFK_ELEMENT_##_element], \
.type = _type, \ .type = _type, \
...@@ -119,15 +123,21 @@ struct mlxsw_afk_element_inst { /* element instance in actual block */ ...@@ -119,15 +123,21 @@ struct mlxsw_afk_element_inst { /* element instance in actual block */
.size = {.bits = _size}, \ .size = {.bits = _size}, \
.name = #_element, \ .name = #_element, \
}, \ }, \
.u32_key_diff = _u32_key_diff, \
} }
#define MLXSW_AFK_ELEMENT_INST_U32(_element, _offset, _shift, _size) \ #define MLXSW_AFK_ELEMENT_INST_U32(_element, _offset, _shift, _size) \
MLXSW_AFK_ELEMENT_INST(MLXSW_AFK_ELEMENT_TYPE_U32, \ MLXSW_AFK_ELEMENT_INST(MLXSW_AFK_ELEMENT_TYPE_U32, \
_element, _offset, _shift, _size) _element, _offset, _shift, _size, 0)
#define MLXSW_AFK_ELEMENT_INST_EXT_U32(_element, _offset, \
_shift, _size, _key_diff) \
MLXSW_AFK_ELEMENT_INST(MLXSW_AFK_ELEMENT_TYPE_U32, \
_element, _offset, _shift, _size, _key_diff)
#define MLXSW_AFK_ELEMENT_INST_BUF(_element, _offset, _size) \ #define MLXSW_AFK_ELEMENT_INST_BUF(_element, _offset, _size) \
MLXSW_AFK_ELEMENT_INST(MLXSW_AFK_ELEMENT_TYPE_BUF, \ MLXSW_AFK_ELEMENT_INST(MLXSW_AFK_ELEMENT_TYPE_BUF, \
_element, _offset, 0, _size) _element, _offset, 0, _size, 0)
struct mlxsw_afk_block { struct mlxsw_afk_block {
u16 encoding; /* block ID */ u16 encoding; /* block ID */
......
...@@ -149,7 +149,7 @@ static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_mac_4[] = { ...@@ -149,7 +149,7 @@ static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_mac_4[] = {
static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_mac_5[] = { static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_mac_5[] = {
MLXSW_AFK_ELEMENT_INST_U32(VID, 0x04, 16, 12), MLXSW_AFK_ELEMENT_INST_U32(VID, 0x04, 16, 12),
MLXSW_AFK_ELEMENT_INST_U32(SRC_SYS_PORT, 0x04, 0, 8), /* RX_ACL_SYSTEM_PORT */ MLXSW_AFK_ELEMENT_INST_EXT_U32(SRC_SYS_PORT, 0x04, 0, 8, -1), /* RX_ACL_SYSTEM_PORT */
}; };
static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_ipv4_0[] = { static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_ipv4_0[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment