qed: Improve the stack space of filter_config()
authorShai Malin <smalin@marvell.com>
Mon, 13 Sep 2021 07:50:24 +0000 (10:50 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 13 Sep 2021 11:41:32 +0000 (12:41 +0100)
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: Naresh Kamboju <naresh.kamboju@linaro.org>
Signed-off-by: Ariel Elior <aelior@marvell.com>
Signed-off-by: Shai Malin <smalin@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/qed/qed_l2.c
drivers/net/ethernet/qlogic/qede/qede_filter.c
include/linux/qed/qed_eth_if.h

index dfaf10e..ba8c7a3 100644 (file)
@@ -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);
 }
 
-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,
                                       enum qed_filter_config_mode mode)
 {
@@ -2904,7 +2885,9 @@ static const struct qed_eth_ops qed_eth_ops_pass = {
        .q_rx_stop = &qed_stop_rxq,
        .q_tx_start = &qed_start_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,
        .eth_cqe_completion = &qed_fp_cqe_completion,
        .get_vport_stats = &qed_get_vport_stats,
index a2e4dfb..f99b085 100644 (file)
@@ -619,30 +619,28 @@ static int qede_set_ucast_rx_mac(struct qede_dev *edev,
                                 enum qed_filter_xcast_params_type opcode,
                                 unsigned char mac[ETH_ALEN])
 {
-       struct qed_filter_params filter_cmd;
+       struct qed_filter_ucast_params ucast;
 
-       memset(&filter_cmd, 0, sizeof(filter_cmd));
-       filter_cmd.type = QED_FILTER_TYPE_UCAST;
-       filter_cmd.filter.ucast.type = opcode;
-       filter_cmd.filter.ucast.mac_valid = 1;
-       ether_addr_copy(filter_cmd.filter.ucast.mac, mac);
+       memset(&ucast, 0, sizeof(ucast));
+       ucast.type = opcode;
+       ucast.mac_valid = 1;
+       ether_addr_copy(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,
                                  enum qed_filter_xcast_params_type opcode,
                                  u16 vid)
 {
-       struct qed_filter_params filter_cmd;
+       struct qed_filter_ucast_params ucast;
 
-       memset(&filter_cmd, 0, sizeof(filter_cmd));
-       filter_cmd.type = QED_FILTER_TYPE_UCAST;
-       filter_cmd.filter.ucast.type = opcode;
-       filter_cmd.filter.ucast.vlan_valid = 1;
-       filter_cmd.filter.ucast.vlan = vid;
+       memset(&ucast, 0, sizeof(ucast));
+       ucast.type = opcode;
+       ucast.vlan_valid = 1;
+       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)
@@ -1057,18 +1055,17 @@ static int qede_set_mcast_rx_mac(struct qede_dev *edev,
                                 enum qed_filter_xcast_params_type opcode,
                                 unsigned char *mac, int num_macs)
 {
-       struct qed_filter_params filter_cmd;
+       struct qed_filter_mcast_params mcast;
        int i;
 
-       memset(&filter_cmd, 0, sizeof(filter_cmd));
-       filter_cmd.type = QED_FILTER_TYPE_MCAST;
-       filter_cmd.filter.mcast.type = opcode;
-       filter_cmd.filter.mcast.num = num_macs;
+       memset(&mcast, 0, sizeof(mcast));
+       mcast.type = opcode;
+       mcast.num = num_macs;
 
        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)
@@ -1194,7 +1191,6 @@ void qede_config_rx_mode(struct net_device *ndev)
 {
        enum qed_filter_rx_mode_type accept_flags;
        struct qede_dev *edev = netdev_priv(ndev);
-       struct qed_filter_params rx_mode;
        unsigned char *uc_macs, *temp;
        struct netdev_hw_addr *ha;
        int rc, uc_count;
@@ -1220,10 +1216,6 @@ void qede_config_rx_mode(struct net_device *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
         * (configure / leave the primary mac)
         */
@@ -1271,8 +1263,7 @@ void qede_config_rx_mode(struct net_device *ndev)
                qede_config_accept_any_vlan(edev, false);
        }
 
-       rx_mode.filter.accept_flags = accept_flags;
-       edev->ops->filter_config(edev->cdev, &rx_mode);
+       edev->ops->filter_config_rx_mode(edev->cdev, accept_flags);
 out:
        kfree(uc_macs);
 }
index 812a4d7..4df0bf0 100644 (file)
@@ -145,12 +145,6 @@ struct qed_filter_mcast_params {
        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 {
        QED_FILTER_TYPE_UCAST,
        QED_FILTER_TYPE_MCAST,
@@ -158,11 +152,6 @@ enum qed_filter_type {
        QED_MAX_FILTER_TYPES,
 };
 
-struct qed_filter_params {
-       enum qed_filter_type type;
-       union qed_filter_type_params filter;
-};
-
 struct qed_tunn_params {
        u16 vxlan_port;
        u8 update_vxlan_port;
@@ -314,8 +303,14 @@ struct qed_eth_ops {
 
        int (*q_tx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle);
 
-       int (*filter_config)(struct qed_dev *cdev,
-                            struct qed_filter_params *params);
+       int (*filter_config_rx_mode)(struct qed_dev *cdev,
+                                    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);