Commit f55e36d5 authored by Shai Malin's avatar Shai Malin Committed by David S. Miller

qed: Improve the stack space of filter_config()

As it was reported and discussed in: https://lore.kernel.org/lkml/CAHk-=whF9F89vsfH8E9TGc0tZA-yhzi2Di8wOtquNB5vRkFX5w@mail.gmail.com/
This patch improves the stack space of qede_config_rx_mode() by
splitting filter_config() to 3 functions and removing the
union qed_filter_type_params.
Reported-by: default avatarNaresh Kamboju <naresh.kamboju@linaro.org>
Signed-off-by: default avatarAriel Elior <aelior@marvell.com>
Signed-off-by: default avatarShai Malin <smalin@marvell.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 626bf91a
...@@ -2763,25 +2763,6 @@ static int qed_configure_filter_mcast(struct qed_dev *cdev, ...@@ -2763,25 +2763,6 @@ static int qed_configure_filter_mcast(struct qed_dev *cdev,
return qed_filter_mcast_cmd(cdev, &mcast, QED_SPQ_MODE_CB, NULL); return qed_filter_mcast_cmd(cdev, &mcast, QED_SPQ_MODE_CB, NULL);
} }
static int qed_configure_filter(struct qed_dev *cdev,
struct qed_filter_params *params)
{
enum qed_filter_rx_mode_type accept_flags;
switch (params->type) {
case QED_FILTER_TYPE_UCAST:
return qed_configure_filter_ucast(cdev, &params->filter.ucast);
case QED_FILTER_TYPE_MCAST:
return qed_configure_filter_mcast(cdev, &params->filter.mcast);
case QED_FILTER_TYPE_RX_MODE:
accept_flags = params->filter.accept_flags;
return qed_configure_filter_rx_mode(cdev, accept_flags);
default:
DP_NOTICE(cdev, "Unknown filter type %d\n", (int)params->type);
return -EINVAL;
}
}
static int qed_configure_arfs_searcher(struct qed_dev *cdev, static int qed_configure_arfs_searcher(struct qed_dev *cdev,
enum qed_filter_config_mode mode) enum qed_filter_config_mode mode)
{ {
...@@ -2904,7 +2885,9 @@ static const struct qed_eth_ops qed_eth_ops_pass = { ...@@ -2904,7 +2885,9 @@ static const struct qed_eth_ops qed_eth_ops_pass = {
.q_rx_stop = &qed_stop_rxq, .q_rx_stop = &qed_stop_rxq,
.q_tx_start = &qed_start_txq, .q_tx_start = &qed_start_txq,
.q_tx_stop = &qed_stop_txq, .q_tx_stop = &qed_stop_txq,
.filter_config = &qed_configure_filter, .filter_config_rx_mode = &qed_configure_filter_rx_mode,
.filter_config_ucast = &qed_configure_filter_ucast,
.filter_config_mcast = &qed_configure_filter_mcast,
.fastpath_stop = &qed_fastpath_stop, .fastpath_stop = &qed_fastpath_stop,
.eth_cqe_completion = &qed_fp_cqe_completion, .eth_cqe_completion = &qed_fp_cqe_completion,
.get_vport_stats = &qed_get_vport_stats, .get_vport_stats = &qed_get_vport_stats,
......
...@@ -619,30 +619,28 @@ static int qede_set_ucast_rx_mac(struct qede_dev *edev, ...@@ -619,30 +619,28 @@ static int qede_set_ucast_rx_mac(struct qede_dev *edev,
enum qed_filter_xcast_params_type opcode, enum qed_filter_xcast_params_type opcode,
unsigned char mac[ETH_ALEN]) unsigned char mac[ETH_ALEN])
{ {
struct qed_filter_params filter_cmd; struct qed_filter_ucast_params ucast;
memset(&filter_cmd, 0, sizeof(filter_cmd)); memset(&ucast, 0, sizeof(ucast));
filter_cmd.type = QED_FILTER_TYPE_UCAST; ucast.type = opcode;
filter_cmd.filter.ucast.type = opcode; ucast.mac_valid = 1;
filter_cmd.filter.ucast.mac_valid = 1; ether_addr_copy(ucast.mac, mac);
ether_addr_copy(filter_cmd.filter.ucast.mac, mac);
return edev->ops->filter_config(edev->cdev, &filter_cmd); return edev->ops->filter_config_ucast(edev->cdev, &ucast);
} }
static int qede_set_ucast_rx_vlan(struct qede_dev *edev, static int qede_set_ucast_rx_vlan(struct qede_dev *edev,
enum qed_filter_xcast_params_type opcode, enum qed_filter_xcast_params_type opcode,
u16 vid) u16 vid)
{ {
struct qed_filter_params filter_cmd; struct qed_filter_ucast_params ucast;
memset(&filter_cmd, 0, sizeof(filter_cmd)); memset(&ucast, 0, sizeof(ucast));
filter_cmd.type = QED_FILTER_TYPE_UCAST; ucast.type = opcode;
filter_cmd.filter.ucast.type = opcode; ucast.vlan_valid = 1;
filter_cmd.filter.ucast.vlan_valid = 1; ucast.vlan = vid;
filter_cmd.filter.ucast.vlan = vid;
return edev->ops->filter_config(edev->cdev, &filter_cmd); return edev->ops->filter_config_ucast(edev->cdev, &ucast);
} }
static int qede_config_accept_any_vlan(struct qede_dev *edev, bool action) static int qede_config_accept_any_vlan(struct qede_dev *edev, bool action)
...@@ -1057,18 +1055,17 @@ static int qede_set_mcast_rx_mac(struct qede_dev *edev, ...@@ -1057,18 +1055,17 @@ static int qede_set_mcast_rx_mac(struct qede_dev *edev,
enum qed_filter_xcast_params_type opcode, enum qed_filter_xcast_params_type opcode,
unsigned char *mac, int num_macs) unsigned char *mac, int num_macs)
{ {
struct qed_filter_params filter_cmd; struct qed_filter_mcast_params mcast;
int i; int i;
memset(&filter_cmd, 0, sizeof(filter_cmd)); memset(&mcast, 0, sizeof(mcast));
filter_cmd.type = QED_FILTER_TYPE_MCAST; mcast.type = opcode;
filter_cmd.filter.mcast.type = opcode; mcast.num = num_macs;
filter_cmd.filter.mcast.num = num_macs;
for (i = 0; i < num_macs; i++, mac += ETH_ALEN) for (i = 0; i < num_macs; i++, mac += ETH_ALEN)
ether_addr_copy(filter_cmd.filter.mcast.mac[i], mac); ether_addr_copy(mcast.mac[i], mac);
return edev->ops->filter_config(edev->cdev, &filter_cmd); return edev->ops->filter_config_mcast(edev->cdev, &mcast);
} }
int qede_set_mac_addr(struct net_device *ndev, void *p) int qede_set_mac_addr(struct net_device *ndev, void *p)
...@@ -1194,7 +1191,6 @@ void qede_config_rx_mode(struct net_device *ndev) ...@@ -1194,7 +1191,6 @@ void qede_config_rx_mode(struct net_device *ndev)
{ {
enum qed_filter_rx_mode_type accept_flags; enum qed_filter_rx_mode_type accept_flags;
struct qede_dev *edev = netdev_priv(ndev); struct qede_dev *edev = netdev_priv(ndev);
struct qed_filter_params rx_mode;
unsigned char *uc_macs, *temp; unsigned char *uc_macs, *temp;
struct netdev_hw_addr *ha; struct netdev_hw_addr *ha;
int rc, uc_count; int rc, uc_count;
...@@ -1220,10 +1216,6 @@ void qede_config_rx_mode(struct net_device *ndev) ...@@ -1220,10 +1216,6 @@ void qede_config_rx_mode(struct net_device *ndev)
netif_addr_unlock_bh(ndev); netif_addr_unlock_bh(ndev);
/* Configure the struct for the Rx mode */
memset(&rx_mode, 0, sizeof(struct qed_filter_params));
rx_mode.type = QED_FILTER_TYPE_RX_MODE;
/* Remove all previous unicast secondary macs and multicast macs /* Remove all previous unicast secondary macs and multicast macs
* (configure / leave the primary mac) * (configure / leave the primary mac)
*/ */
...@@ -1271,8 +1263,7 @@ void qede_config_rx_mode(struct net_device *ndev) ...@@ -1271,8 +1263,7 @@ void qede_config_rx_mode(struct net_device *ndev)
qede_config_accept_any_vlan(edev, false); qede_config_accept_any_vlan(edev, false);
} }
rx_mode.filter.accept_flags = accept_flags; edev->ops->filter_config_rx_mode(edev->cdev, accept_flags);
edev->ops->filter_config(edev->cdev, &rx_mode);
out: out:
kfree(uc_macs); kfree(uc_macs);
} }
......
...@@ -145,12 +145,6 @@ struct qed_filter_mcast_params { ...@@ -145,12 +145,6 @@ struct qed_filter_mcast_params {
unsigned char mac[64][ETH_ALEN]; unsigned char mac[64][ETH_ALEN];
}; };
union qed_filter_type_params {
enum qed_filter_rx_mode_type accept_flags;
struct qed_filter_ucast_params ucast;
struct qed_filter_mcast_params mcast;
};
enum qed_filter_type { enum qed_filter_type {
QED_FILTER_TYPE_UCAST, QED_FILTER_TYPE_UCAST,
QED_FILTER_TYPE_MCAST, QED_FILTER_TYPE_MCAST,
...@@ -158,11 +152,6 @@ enum qed_filter_type { ...@@ -158,11 +152,6 @@ enum qed_filter_type {
QED_MAX_FILTER_TYPES, QED_MAX_FILTER_TYPES,
}; };
struct qed_filter_params {
enum qed_filter_type type;
union qed_filter_type_params filter;
};
struct qed_tunn_params { struct qed_tunn_params {
u16 vxlan_port; u16 vxlan_port;
u8 update_vxlan_port; u8 update_vxlan_port;
...@@ -314,8 +303,14 @@ struct qed_eth_ops { ...@@ -314,8 +303,14 @@ struct qed_eth_ops {
int (*q_tx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle); int (*q_tx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle);
int (*filter_config)(struct qed_dev *cdev, int (*filter_config_rx_mode)(struct qed_dev *cdev,
struct qed_filter_params *params); enum qed_filter_rx_mode_type type);
int (*filter_config_ucast)(struct qed_dev *cdev,
struct qed_filter_ucast_params *params);
int (*filter_config_mcast)(struct qed_dev *cdev,
struct qed_filter_mcast_params *params);
int (*fastpath_stop)(struct qed_dev *cdev); int (*fastpath_stop)(struct qed_dev *cdev);
......
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