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

rocker: remove trans parameter to rocker_cmd_exec function

The only purpose of passing this parameter is to check for
prepare phase. The only reason for a failure in that state is if
TLVs don't fit into descriptor. That is highly unlikely and if that
happens, it is a driver bug. So remove this parameter from
rocker_cmd_exec, and check for prepare phase in caller.
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ca0a5f2a
......@@ -1337,8 +1337,7 @@ typedef int (*rocker_cmd_proc_cb_t)(const struct rocker_port *rocker_port,
const struct rocker_desc_info *desc_info,
void *priv);
static int rocker_cmd_exec(struct rocker_port *rocker_port,
struct switchdev_trans *trans, int flags,
static int rocker_cmd_exec(struct rocker_port *rocker_port, int flags,
rocker_cmd_prep_cb_t prepare, void *prepare_priv,
rocker_cmd_proc_cb_t process, void *process_priv)
{
......@@ -1367,7 +1366,6 @@ static int rocker_cmd_exec(struct rocker_port *rocker_port,
return err;
}
if (!switchdev_trans_ph_prepare(trans))
rocker_desc_head_set(rocker, &rocker->cmd_ring, desc_info);
spin_unlock_irqrestore(&rocker->cmd_ring_lock, lock_flags);
......@@ -1375,7 +1373,6 @@ static int rocker_cmd_exec(struct rocker_port *rocker_port,
if (nowait)
return 0;
if (!switchdev_trans_ph_prepare(trans))
if (!rocker_wait_event_timeout(wait, HZ / 10))
return -EIO;
......@@ -1650,7 +1647,7 @@ rocker_cmd_set_port_learning_prep(const struct rocker_port *rocker_port,
static int rocker_cmd_get_port_settings_ethtool(struct rocker_port *rocker_port,
struct ethtool_cmd *ecmd)
{
return rocker_cmd_exec(rocker_port, NULL, 0,
return rocker_cmd_exec(rocker_port, 0,
rocker_cmd_get_port_settings_prep, NULL,
rocker_cmd_get_port_settings_ethtool_proc,
ecmd);
......@@ -1659,7 +1656,7 @@ static int rocker_cmd_get_port_settings_ethtool(struct rocker_port *rocker_port,
static int rocker_cmd_get_port_settings_macaddr(struct rocker_port *rocker_port,
unsigned char *macaddr)
{
return rocker_cmd_exec(rocker_port, NULL, 0,
return rocker_cmd_exec(rocker_port, 0,
rocker_cmd_get_port_settings_prep, NULL,
rocker_cmd_get_port_settings_macaddr_proc,
macaddr);
......@@ -1668,7 +1665,7 @@ static int rocker_cmd_get_port_settings_macaddr(struct rocker_port *rocker_port,
static int rocker_cmd_get_port_settings_mode(struct rocker_port *rocker_port,
u8 *p_mode)
{
return rocker_cmd_exec(rocker_port, NULL, 0,
return rocker_cmd_exec(rocker_port, 0,
rocker_cmd_get_port_settings_prep, NULL,
rocker_cmd_get_port_settings_mode_proc, p_mode);
}
......@@ -1676,7 +1673,7 @@ static int rocker_cmd_get_port_settings_mode(struct rocker_port *rocker_port,
static int rocker_cmd_set_port_settings_ethtool(struct rocker_port *rocker_port,
struct ethtool_cmd *ecmd)
{
return rocker_cmd_exec(rocker_port, NULL, 0,
return rocker_cmd_exec(rocker_port, 0,
rocker_cmd_set_port_settings_ethtool_prep,
ecmd, NULL, NULL);
}
......@@ -1684,7 +1681,7 @@ static int rocker_cmd_set_port_settings_ethtool(struct rocker_port *rocker_port,
static int rocker_cmd_set_port_settings_macaddr(struct rocker_port *rocker_port,
unsigned char *macaddr)
{
return rocker_cmd_exec(rocker_port, NULL, 0,
return rocker_cmd_exec(rocker_port, 0,
rocker_cmd_set_port_settings_macaddr_prep,
macaddr, NULL, NULL);
}
......@@ -1692,16 +1689,15 @@ static int rocker_cmd_set_port_settings_macaddr(struct rocker_port *rocker_port,
static int rocker_cmd_set_port_settings_mtu(struct rocker_port *rocker_port,
int mtu)
{
return rocker_cmd_exec(rocker_port, NULL, 0,
return rocker_cmd_exec(rocker_port, 0,
rocker_cmd_set_port_settings_mtu_prep,
&mtu, NULL, NULL);
}
static int rocker_port_set_learning(struct rocker_port *rocker_port,
struct switchdev_trans *trans,
bool learning)
{
return rocker_cmd_exec(rocker_port, trans, 0,
return rocker_cmd_exec(rocker_port, 0,
rocker_cmd_set_port_learning_prep,
&learning, NULL, NULL);
}
......@@ -2578,8 +2574,11 @@ static int rocker_flow_tbl_add(struct rocker_port *rocker_port,
spin_unlock_irqrestore(&rocker->flow_tbl_lock, lock_flags);
return rocker_cmd_exec(rocker_port, trans, flags,
rocker_cmd_flow_tbl_add, found, NULL, NULL);
if (!switchdev_trans_ph_prepare(trans))
return rocker_cmd_exec(rocker_port, flags,
rocker_cmd_flow_tbl_add,
found, NULL, NULL);
return 0;
}
static int rocker_flow_tbl_del(struct rocker_port *rocker_port,
......@@ -2609,7 +2608,8 @@ static int rocker_flow_tbl_del(struct rocker_port *rocker_port,
rocker_kfree(trans, match);
if (found) {
err = rocker_cmd_exec(rocker_port, trans, flags,
if (!switchdev_trans_ph_prepare(trans))
err = rocker_cmd_exec(rocker_port, flags,
rocker_cmd_flow_tbl_del,
found, NULL, NULL);
rocker_kfree(trans, found);
......@@ -2899,8 +2899,11 @@ static int rocker_group_tbl_add(struct rocker_port *rocker_port,
spin_unlock_irqrestore(&rocker->group_tbl_lock, lock_flags);
return rocker_cmd_exec(rocker_port, trans, flags,
rocker_cmd_group_tbl_add, found, NULL, NULL);
if (!switchdev_trans_ph_prepare(trans))
return rocker_cmd_exec(rocker_port, flags,
rocker_cmd_group_tbl_add,
found, NULL, NULL);
return 0;
}
static int rocker_group_tbl_del(struct rocker_port *rocker_port,
......@@ -2927,7 +2930,8 @@ static int rocker_group_tbl_del(struct rocker_port *rocker_port,
rocker_group_tbl_entry_free(trans, match);
if (found) {
err = rocker_cmd_exec(rocker_port, trans, flags,
if (!switchdev_trans_ph_prepare(trans))
err = rocker_cmd_exec(rocker_port, flags,
rocker_cmd_group_tbl_del,
found, NULL, NULL);
rocker_group_tbl_entry_free(trans, found);
......@@ -4405,7 +4409,7 @@ static int rocker_port_get_phys_port_name(struct net_device *dev,
struct port_name name = { .buf = buf, .len = len };
int err;
err = rocker_cmd_exec(rocker_port, NULL, 0,
err = rocker_cmd_exec(rocker_port, 0,
rocker_cmd_get_port_settings_prep, NULL,
rocker_cmd_get_port_settings_phys_name_proc,
&name);
......@@ -4493,8 +4497,9 @@ static int rocker_port_brport_flags_set(struct rocker_port *rocker_port,
orig_flags = rocker_port->brport_flags;
rocker_port->brport_flags = brport_flags;
if ((orig_flags ^ rocker_port->brport_flags) & BR_LEARNING)
err = rocker_port_set_learning(rocker_port, trans,
if ((orig_flags ^ rocker_port->brport_flags) & BR_LEARNING &&
!switchdev_trans_ph_prepare(trans))
err = rocker_port_set_learning(rocker_port,
!!(rocker_port->brport_flags & BR_LEARNING));
if (switchdev_trans_ph_prepare(trans))
......@@ -4957,7 +4962,7 @@ rocker_cmd_get_port_stats_ethtool_proc(const struct rocker_port *rocker_port,
static int rocker_cmd_get_port_stats_ethtool(struct rocker_port *rocker_port,
void *priv)
{
return rocker_cmd_exec(rocker_port, NULL, 0,
return rocker_cmd_exec(rocker_port, 0,
rocker_cmd_get_port_stats_prep, NULL,
rocker_cmd_get_port_stats_ethtool_proc,
priv);
......@@ -5230,7 +5235,7 @@ static int rocker_probe_port(struct rocker *rocker, unsigned int port_number)
switchdev_port_fwd_mark_set(rocker_port->dev, NULL, false);
rocker_port_set_learning(rocker_port, NULL,
rocker_port_set_learning(rocker_port,
!!(rocker_port->brport_flags & BR_LEARNING));
err = rocker_port_ig_tbl(rocker_port, NULL, 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