Commit c00e8a69 authored by Vadym Kochan's avatar Vadym Kochan Committed by David S. Miller

net: marvell: prestera: align flood setting according to latest firmware version

Latest FW IPC flood message format was changed to configure uc/mc
flooding separately, so change code according to this.
Signed-off-by: default avatarVadym Kochan <vkochan@marvell.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 263805c8
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
/* Copyright (c) 2019-2020 Marvell International Ltd. All rights reserved */ /* Copyright (c) 2019-2020 Marvell International Ltd. All rights reserved */
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/if_bridge.h>
#include <linux/ethtool.h> #include <linux/ethtool.h>
#include <linux/list.h> #include <linux/list.h>
...@@ -85,6 +86,11 @@ enum { ...@@ -85,6 +86,11 @@ enum {
PRESTERA_PORT_TP_AUTO, PRESTERA_PORT_TP_AUTO,
}; };
enum {
PRESTERA_PORT_FLOOD_TYPE_UC = 0,
PRESTERA_PORT_FLOOD_TYPE_MC = 1,
};
enum { enum {
PRESTERA_PORT_GOOD_OCTETS_RCV_CNT, PRESTERA_PORT_GOOD_OCTETS_RCV_CNT,
PRESTERA_PORT_BAD_OCTETS_RCV_CNT, PRESTERA_PORT_BAD_OCTETS_RCV_CNT,
...@@ -188,6 +194,11 @@ struct prestera_msg_port_mdix_param { ...@@ -188,6 +194,11 @@ struct prestera_msg_port_mdix_param {
u8 admin_mode; u8 admin_mode;
}; };
struct prestera_msg_port_flood_param {
u8 type;
u8 enable;
};
union prestera_msg_port_param { union prestera_msg_port_param {
u8 admin_state; u8 admin_state;
u8 oper_state; u8 oper_state;
...@@ -205,6 +216,7 @@ union prestera_msg_port_param { ...@@ -205,6 +216,7 @@ union prestera_msg_port_param {
struct prestera_msg_port_mdix_param mdix; struct prestera_msg_port_mdix_param mdix;
struct prestera_msg_port_autoneg_param autoneg; struct prestera_msg_port_autoneg_param autoneg;
struct prestera_msg_port_cap_param cap; struct prestera_msg_port_cap_param cap;
struct prestera_msg_port_flood_param flood_ext;
}; };
struct prestera_msg_port_attr_req { struct prestera_msg_port_attr_req {
...@@ -988,7 +1000,43 @@ int prestera_hw_port_learning_set(struct prestera_port *port, bool enable) ...@@ -988,7 +1000,43 @@ int prestera_hw_port_learning_set(struct prestera_port *port, bool enable)
&req.cmd, sizeof(req)); &req.cmd, sizeof(req));
} }
int prestera_hw_port_flood_set(struct prestera_port *port, bool flood) static int prestera_hw_port_uc_flood_set(struct prestera_port *port, bool flood)
{
struct prestera_msg_port_attr_req req = {
.attr = PRESTERA_CMD_PORT_ATTR_FLOOD,
.port = port->hw_id,
.dev = port->dev_id,
.param = {
.flood_ext = {
.type = PRESTERA_PORT_FLOOD_TYPE_UC,
.enable = flood,
}
}
};
return prestera_cmd(port->sw, PRESTERA_CMD_TYPE_PORT_ATTR_SET,
&req.cmd, sizeof(req));
}
static int prestera_hw_port_mc_flood_set(struct prestera_port *port, bool flood)
{
struct prestera_msg_port_attr_req req = {
.attr = PRESTERA_CMD_PORT_ATTR_FLOOD,
.port = port->hw_id,
.dev = port->dev_id,
.param = {
.flood_ext = {
.type = PRESTERA_PORT_FLOOD_TYPE_MC,
.enable = flood,
}
}
};
return prestera_cmd(port->sw, PRESTERA_CMD_TYPE_PORT_ATTR_SET,
&req.cmd, sizeof(req));
}
static int prestera_hw_port_flood_set_v2(struct prestera_port *port, bool flood)
{ {
struct prestera_msg_port_attr_req req = { struct prestera_msg_port_attr_req req = {
.attr = PRESTERA_CMD_PORT_ATTR_FLOOD, .attr = PRESTERA_CMD_PORT_ATTR_FLOOD,
...@@ -1003,6 +1051,41 @@ int prestera_hw_port_flood_set(struct prestera_port *port, bool flood) ...@@ -1003,6 +1051,41 @@ int prestera_hw_port_flood_set(struct prestera_port *port, bool flood)
&req.cmd, sizeof(req)); &req.cmd, sizeof(req));
} }
int prestera_hw_port_flood_set(struct prestera_port *port, unsigned long mask,
unsigned long val)
{
int err;
if (port->sw->dev->fw_rev.maj <= 2) {
if (!(mask & BR_FLOOD))
return 0;
return prestera_hw_port_flood_set_v2(port, val & BR_FLOOD);
}
if (mask & BR_FLOOD) {
err = prestera_hw_port_uc_flood_set(port, val & BR_FLOOD);
if (err)
goto err_uc_flood;
}
if (mask & BR_MCAST_FLOOD) {
err = prestera_hw_port_mc_flood_set(port, val & BR_MCAST_FLOOD);
if (err)
goto err_mc_flood;
}
return 0;
err_mc_flood:
prestera_hw_port_mc_flood_set(port, 0);
err_uc_flood:
if (mask & BR_FLOOD)
prestera_hw_port_uc_flood_set(port, 0);
return err;
}
int prestera_hw_vlan_create(struct prestera_switch *sw, u16 vid) int prestera_hw_vlan_create(struct prestera_switch *sw, u16 vid)
{ {
struct prestera_msg_vlan_req req = { struct prestera_msg_vlan_req req = {
......
...@@ -138,7 +138,8 @@ int prestera_hw_port_mdix_get(const struct prestera_port *port, u8 *status, ...@@ -138,7 +138,8 @@ int prestera_hw_port_mdix_get(const struct prestera_port *port, u8 *status,
int prestera_hw_port_mdix_set(const struct prestera_port *port, u8 mode); int prestera_hw_port_mdix_set(const struct prestera_port *port, u8 mode);
int prestera_hw_port_speed_get(const struct prestera_port *port, u32 *speed); int prestera_hw_port_speed_get(const struct prestera_port *port, u32 *speed);
int prestera_hw_port_learning_set(struct prestera_port *port, bool enable); int prestera_hw_port_learning_set(struct prestera_port *port, bool enable);
int prestera_hw_port_flood_set(struct prestera_port *port, bool flood); int prestera_hw_port_flood_set(struct prestera_port *port, unsigned long mask,
unsigned long val);
int prestera_hw_port_accept_frm_type(struct prestera_port *port, int prestera_hw_port_accept_frm_type(struct prestera_port *port,
enum prestera_accept_frm_type type); enum prestera_accept_frm_type type);
/* Vlan API */ /* Vlan API */
......
...@@ -404,7 +404,8 @@ prestera_bridge_1d_port_join(struct prestera_bridge_port *br_port) ...@@ -404,7 +404,8 @@ prestera_bridge_1d_port_join(struct prestera_bridge_port *br_port)
if (err) if (err)
return err; return err;
err = prestera_hw_port_flood_set(port, br_port->flags & BR_FLOOD); err = prestera_hw_port_flood_set(port, BR_FLOOD | BR_MCAST_FLOOD,
br_port->flags);
if (err) if (err)
goto err_port_flood_set; goto err_port_flood_set;
...@@ -415,7 +416,6 @@ prestera_bridge_1d_port_join(struct prestera_bridge_port *br_port) ...@@ -415,7 +416,6 @@ prestera_bridge_1d_port_join(struct prestera_bridge_port *br_port)
return 0; return 0;
err_port_learning_set: err_port_learning_set:
prestera_hw_port_flood_set(port, false);
err_port_flood_set: err_port_flood_set:
prestera_hw_bridge_port_delete(port, bridge->bridge_id); prestera_hw_bridge_port_delete(port, bridge->bridge_id);
...@@ -528,7 +528,7 @@ static void prestera_port_bridge_leave(struct prestera_port *port, ...@@ -528,7 +528,7 @@ static void prestera_port_bridge_leave(struct prestera_port *port,
prestera_bridge_1d_port_leave(br_port); prestera_bridge_1d_port_leave(br_port);
prestera_hw_port_learning_set(port, false); prestera_hw_port_learning_set(port, false);
prestera_hw_port_flood_set(port, false); prestera_hw_port_flood_set(port, BR_FLOOD | BR_MCAST_FLOOD, 0);
prestera_port_vid_stp_set(port, PRESTERA_VID_ALL, BR_STATE_FORWARDING); prestera_port_vid_stp_set(port, PRESTERA_VID_ALL, BR_STATE_FORWARDING);
prestera_bridge_port_put(br_port); prestera_bridge_port_put(br_port);
} }
...@@ -590,11 +590,9 @@ static int prestera_port_attr_br_flags_set(struct prestera_port *port, ...@@ -590,11 +590,9 @@ static int prestera_port_attr_br_flags_set(struct prestera_port *port,
if (!br_port) if (!br_port)
return 0; return 0;
if (flags.mask & BR_FLOOD) { err = prestera_hw_port_flood_set(port, flags.mask, flags.val);
err = prestera_hw_port_flood_set(port, flags.val & BR_FLOOD); if (err)
if (err) return err;
return err;
}
if (flags.mask & BR_LEARNING) { if (flags.mask & BR_LEARNING) {
err = prestera_hw_port_learning_set(port, err = prestera_hw_port_learning_set(port,
...@@ -901,7 +899,8 @@ prestera_port_vlan_bridge_join(struct prestera_port_vlan *port_vlan, ...@@ -901,7 +899,8 @@ prestera_port_vlan_bridge_join(struct prestera_port_vlan *port_vlan,
if (port_vlan->br_port) if (port_vlan->br_port)
return 0; return 0;
err = prestera_hw_port_flood_set(port, br_port->flags & BR_FLOOD); err = prestera_hw_port_flood_set(port, BR_FLOOD | BR_MCAST_FLOOD,
br_port->flags);
if (err) if (err)
return err; return err;
......
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