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

mlxsw: core: Remove priv from listener equality comparison

During packet receive, only the first matching RX listener
in rx_listener_list is going to get the packet. So there is no
meaning in registering two equal listeners with different privs.
Remove priv from equality comparison and disable possibility
of doing it.
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 b32bd7f7
...@@ -1457,14 +1457,12 @@ static bool __is_rx_listener_equal(const struct mlxsw_rx_listener *rxl_a, ...@@ -1457,14 +1457,12 @@ static bool __is_rx_listener_equal(const struct mlxsw_rx_listener *rxl_a,
static struct mlxsw_rx_listener_item * static struct mlxsw_rx_listener_item *
__find_rx_listener_item(struct mlxsw_core *mlxsw_core, __find_rx_listener_item(struct mlxsw_core *mlxsw_core,
const struct mlxsw_rx_listener *rxl, const struct mlxsw_rx_listener *rxl)
void *priv)
{ {
struct mlxsw_rx_listener_item *rxl_item; struct mlxsw_rx_listener_item *rxl_item;
list_for_each_entry(rxl_item, &mlxsw_core->rx_listener_list, list) { list_for_each_entry(rxl_item, &mlxsw_core->rx_listener_list, list) {
if (__is_rx_listener_equal(&rxl_item->rxl, rxl) && if (__is_rx_listener_equal(&rxl_item->rxl, rxl))
rxl_item->priv == priv)
return rxl_item; return rxl_item;
} }
return NULL; return NULL;
...@@ -1476,7 +1474,7 @@ int mlxsw_core_rx_listener_register(struct mlxsw_core *mlxsw_core, ...@@ -1476,7 +1474,7 @@ int mlxsw_core_rx_listener_register(struct mlxsw_core *mlxsw_core,
{ {
struct mlxsw_rx_listener_item *rxl_item; struct mlxsw_rx_listener_item *rxl_item;
rxl_item = __find_rx_listener_item(mlxsw_core, rxl, priv); rxl_item = __find_rx_listener_item(mlxsw_core, rxl);
if (rxl_item) if (rxl_item)
return -EEXIST; return -EEXIST;
rxl_item = kmalloc(sizeof(*rxl_item), GFP_KERNEL); rxl_item = kmalloc(sizeof(*rxl_item), GFP_KERNEL);
...@@ -1491,12 +1489,11 @@ int mlxsw_core_rx_listener_register(struct mlxsw_core *mlxsw_core, ...@@ -1491,12 +1489,11 @@ int mlxsw_core_rx_listener_register(struct mlxsw_core *mlxsw_core,
EXPORT_SYMBOL(mlxsw_core_rx_listener_register); EXPORT_SYMBOL(mlxsw_core_rx_listener_register);
void mlxsw_core_rx_listener_unregister(struct mlxsw_core *mlxsw_core, void mlxsw_core_rx_listener_unregister(struct mlxsw_core *mlxsw_core,
const struct mlxsw_rx_listener *rxl, const struct mlxsw_rx_listener *rxl)
void *priv)
{ {
struct mlxsw_rx_listener_item *rxl_item; struct mlxsw_rx_listener_item *rxl_item;
rxl_item = __find_rx_listener_item(mlxsw_core, rxl, priv); rxl_item = __find_rx_listener_item(mlxsw_core, rxl);
if (!rxl_item) if (!rxl_item)
return; return;
list_del_rcu(&rxl_item->list); list_del_rcu(&rxl_item->list);
...@@ -1534,14 +1531,12 @@ static bool __is_event_listener_equal(const struct mlxsw_event_listener *el_a, ...@@ -1534,14 +1531,12 @@ static bool __is_event_listener_equal(const struct mlxsw_event_listener *el_a,
static struct mlxsw_event_listener_item * static struct mlxsw_event_listener_item *
__find_event_listener_item(struct mlxsw_core *mlxsw_core, __find_event_listener_item(struct mlxsw_core *mlxsw_core,
const struct mlxsw_event_listener *el, const struct mlxsw_event_listener *el)
void *priv)
{ {
struct mlxsw_event_listener_item *el_item; struct mlxsw_event_listener_item *el_item;
list_for_each_entry(el_item, &mlxsw_core->event_listener_list, list) { list_for_each_entry(el_item, &mlxsw_core->event_listener_list, list) {
if (__is_event_listener_equal(&el_item->el, el) && if (__is_event_listener_equal(&el_item->el, el))
el_item->priv == priv)
return el_item; return el_item;
} }
return NULL; return NULL;
...@@ -1559,7 +1554,7 @@ int mlxsw_core_event_listener_register(struct mlxsw_core *mlxsw_core, ...@@ -1559,7 +1554,7 @@ int mlxsw_core_event_listener_register(struct mlxsw_core *mlxsw_core,
.trap_id = el->trap_id, .trap_id = el->trap_id,
}; };
el_item = __find_event_listener_item(mlxsw_core, el, priv); el_item = __find_event_listener_item(mlxsw_core, el);
if (el_item) if (el_item)
return -EEXIST; return -EEXIST;
el_item = kmalloc(sizeof(*el_item), GFP_KERNEL); el_item = kmalloc(sizeof(*el_item), GFP_KERNEL);
...@@ -1586,8 +1581,7 @@ int mlxsw_core_event_listener_register(struct mlxsw_core *mlxsw_core, ...@@ -1586,8 +1581,7 @@ int mlxsw_core_event_listener_register(struct mlxsw_core *mlxsw_core,
EXPORT_SYMBOL(mlxsw_core_event_listener_register); EXPORT_SYMBOL(mlxsw_core_event_listener_register);
void mlxsw_core_event_listener_unregister(struct mlxsw_core *mlxsw_core, void mlxsw_core_event_listener_unregister(struct mlxsw_core *mlxsw_core,
const struct mlxsw_event_listener *el, const struct mlxsw_event_listener *el)
void *priv)
{ {
struct mlxsw_event_listener_item *el_item; struct mlxsw_event_listener_item *el_item;
const struct mlxsw_rx_listener rxl = { const struct mlxsw_rx_listener rxl = {
...@@ -1596,10 +1590,10 @@ void mlxsw_core_event_listener_unregister(struct mlxsw_core *mlxsw_core, ...@@ -1596,10 +1590,10 @@ void mlxsw_core_event_listener_unregister(struct mlxsw_core *mlxsw_core,
.trap_id = el->trap_id, .trap_id = el->trap_id,
}; };
el_item = __find_event_listener_item(mlxsw_core, el, priv); el_item = __find_event_listener_item(mlxsw_core, el);
if (!el_item) if (!el_item)
return; return;
mlxsw_core_rx_listener_unregister(mlxsw_core, &rxl, el_item); mlxsw_core_rx_listener_unregister(mlxsw_core, &rxl);
list_del(&el_item->list); list_del(&el_item->list);
kfree(el_item); kfree(el_item);
} }
...@@ -1625,12 +1619,10 @@ static void mlxsw_core_listener_unregister(struct mlxsw_core *mlxsw_core, ...@@ -1625,12 +1619,10 @@ static void mlxsw_core_listener_unregister(struct mlxsw_core *mlxsw_core,
{ {
if (listener->is_event) if (listener->is_event)
mlxsw_core_event_listener_unregister(mlxsw_core, mlxsw_core_event_listener_unregister(mlxsw_core,
&listener->event_listener, &listener->event_listener);
priv);
else else
mlxsw_core_rx_listener_unregister(mlxsw_core, mlxsw_core_rx_listener_unregister(mlxsw_core,
&listener->rx_listener, &listener->rx_listener);
priv);
} }
int mlxsw_core_trap_register(struct mlxsw_core *mlxsw_core, int mlxsw_core_trap_register(struct mlxsw_core *mlxsw_core,
......
...@@ -116,15 +116,13 @@ int mlxsw_core_rx_listener_register(struct mlxsw_core *mlxsw_core, ...@@ -116,15 +116,13 @@ int mlxsw_core_rx_listener_register(struct mlxsw_core *mlxsw_core,
const struct mlxsw_rx_listener *rxl, const struct mlxsw_rx_listener *rxl,
void *priv); void *priv);
void mlxsw_core_rx_listener_unregister(struct mlxsw_core *mlxsw_core, void mlxsw_core_rx_listener_unregister(struct mlxsw_core *mlxsw_core,
const struct mlxsw_rx_listener *rxl, const struct mlxsw_rx_listener *rxl);
void *priv);
int mlxsw_core_event_listener_register(struct mlxsw_core *mlxsw_core, int mlxsw_core_event_listener_register(struct mlxsw_core *mlxsw_core,
const struct mlxsw_event_listener *el, const struct mlxsw_event_listener *el,
void *priv); void *priv);
void mlxsw_core_event_listener_unregister(struct mlxsw_core *mlxsw_core, void mlxsw_core_event_listener_unregister(struct mlxsw_core *mlxsw_core,
const struct mlxsw_event_listener *el, const struct mlxsw_event_listener *el);
void *priv);
int mlxsw_core_trap_register(struct mlxsw_core *mlxsw_core, int mlxsw_core_trap_register(struct mlxsw_core *mlxsw_core,
const struct mlxsw_listener *listener, const struct mlxsw_listener *listener,
......
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