[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240210021000.2011419-1-jesse.brandeburg@intel.com>
Date: Fri, 9 Feb 2024 18:09:57 -0800
From: Jesse Brandeburg <jesse.brandeburg@...el.com>
To: intel-wired-lan@...ts.osuosl.org
Cc: Jesse Brandeburg <jesse.brandeburg@...el.com>,
netdev@...r.kernel.org,
Ariel Elior <aelior@...vell.com>,
Sudarsana Kalluru <skalluru@...vell.com>,
Manish Chopra <manishc@...vell.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Raju Rangoju <rajur@...lsio.com>,
Tony Nguyen <anthony.l.nguyen@...el.com>,
Jay Vosburgh <jay.vosburgh@...onical.com>,
Kory Maincent <kory.maincent@...tlin.com>,
Subbaraya Sundeep <sbhatta@...vell.com>,
Richard Cochran <richardcochran@...il.com>,
Maxim Georgiev <glipus@...il.com>,
Emeel Hakim <ehakim@...dia.com>,
Vadim Fedorenko <vadim.fedorenko@...ux.dev>
Subject: [PATCH RFC net-next v1] net: rework FCOE and RFS ops
[ Sent as RFC to gauge whether this is better than what we have ]
As demonstrated with the macros in include/linux/pm.h, from commit
1a3c7bb08826 ("PM: core: Add new *_PM_OPS macros, deprecate old ones"),
the networking layer can benefit from some of the same logic to remove
ifdef CONFIG_FOO blocks from code and move the complicated management of
=y and =m variants causing "unused function" warnings from the
developer, and put them into the header file.
This adds several new helpers for drivers to use instead of ifdefs
SET_FCOE_OPS()
SET_FCOE_GET_WWN_OPS()
SET_RFS_ACCEL_OPS()
And the idea is that you can get rid of #ifdef CONFIG_BLAH around the
declarations of these functions that are only called from an ops
pointer, and you can declare the population of the ops members with the
new macros which avoid filling in values when the ifdef is not enabled.
NOTE:
There is a bunch of code in ixgbe under IXGBE_FCOE defines which is only
defined when CONFIG_FCOE is defined, but I didn't want to fix hundreds
of those so just left most of them.
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@...el.com>
---
.../net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 2 --
.../net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 2 --
.../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 5 +--
.../net/ethernet/chelsio/cxgb4/cxgb4_main.c | 4 +--
drivers/net/ethernet/intel/ice/ice_arfs.h | 8 -----
drivers/net/ethernet/intel/ice/ice_main.c | 4 +--
drivers/net/ethernet/intel/ixgbe/ixgbe.h | 7 ----
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 21 +++++-------
.../net/ethernet/intel/ixgbe/ixgbe_sriov.c | 8 ++---
include/linux/netdevice.h | 34 +++++++++++++++++--
net/8021q/vlan_dev.c | 18 +++-------
11 files changed, 49 insertions(+), 64 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index e9c1e1bb5580..0300e40c7ca6 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -4860,7 +4860,6 @@ int bnx2x_get_link_cfg_idx(struct bnx2x *bp)
return LINK_CONFIG_IDX(sel_phy_idx);
}
-#ifdef NETDEV_FCOE_WWNN
int bnx2x_fcoe_get_wwn(struct net_device *dev, u64 *wwn, int type)
{
struct bnx2x *bp = netdev_priv(dev);
@@ -4882,7 +4881,6 @@ int bnx2x_fcoe_get_wwn(struct net_device *dev, u64 *wwn, int type)
return 0;
}
-#endif
/* called with rtnl_lock */
int bnx2x_change_mtu(struct net_device *dev, int new_mtu)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
index d8b1824c334d..afcef4a4d680 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
@@ -594,7 +594,6 @@ void bnx2x_free_mem_bp(struct bnx2x *bp);
*/
int bnx2x_change_mtu(struct net_device *dev, int new_mtu);
-#ifdef NETDEV_FCOE_WWNN
/**
* bnx2x_fcoe_get_wwn - return the requested WWN value for this port
*
@@ -604,7 +603,6 @@ int bnx2x_change_mtu(struct net_device *dev, int new_mtu);
*
*/
int bnx2x_fcoe_get_wwn(struct net_device *dev, u64 *wwn, int type);
-#endif
netdev_features_t bnx2x_fix_features(struct net_device *dev,
netdev_features_t features);
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 0d8e61c63c7c..e2795a6047b8 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -13030,10 +13030,7 @@ static const struct net_device_ops bnx2x_netdev_ops = {
.ndo_get_vf_config = bnx2x_get_vf_config,
.ndo_set_vf_spoofchk = bnx2x_set_vf_spoofchk,
#endif
-#ifdef NETDEV_FCOE_WWNN
- .ndo_fcoe_get_wwn = bnx2x_fcoe_get_wwn,
-#endif
-
+ SET_FCOE_GET_WWN_OPS(bnx2x_fcoe_get_wwn)
.ndo_get_phys_port_id = bnx2x_get_phys_port_id,
.ndo_set_vf_link_state = bnx2x_set_vf_link_state,
.ndo_features_check = bnx2x_features_check,
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 2eb33a727bba..48dd7c89374d 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -3877,8 +3877,8 @@ static const struct net_device_ops cxgb4_netdev_ops = {
.ndo_poll_controller = cxgb_netpoll,
#endif
#ifdef CONFIG_CHELSIO_T4_FCOE
- .ndo_fcoe_enable = cxgb_fcoe_enable,
- .ndo_fcoe_disable = cxgb_fcoe_disable,
+ SET_FCOE_OPS(cxgb_fcoe_enable, cxgb_fcoe_disable,
+ NULL, NULL, NULL, NULL)
#endif /* CONFIG_CHELSIO_T4_FCOE */
.ndo_set_tx_maxrate = cxgb_set_tx_maxrate,
.ndo_setup_tc = cxgb_setup_tc,
diff --git a/drivers/net/ethernet/intel/ice/ice_arfs.h b/drivers/net/ethernet/intel/ice/ice_arfs.h
index 9669ad9bf7b5..e09fff33fcdd 100644
--- a/drivers/net/ethernet/intel/ice/ice_arfs.h
+++ b/drivers/net/ethernet/intel/ice/ice_arfs.h
@@ -67,14 +67,6 @@ static inline int ice_set_cpu_rx_rmap(struct ice_vsi __always_unused *vsi)
return 0;
}
-static inline int
-ice_rx_flow_steer(struct net_device __always_unused *netdev,
- const struct sk_buff __always_unused *skb,
- u16 __always_unused rxq_idx, u32 __always_unused flow_id)
-{
- return -EOPNOTSUPP;
-}
-
static inline bool
ice_is_arfs_using_perfect_flow(struct ice_hw __always_unused *hw,
enum ice_fltr_ptype __always_unused flow_type)
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index dd4a9bc0dfdc..970bf53b4823 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -9516,11 +9516,9 @@ static const struct net_device_ops ice_netdev_ops = {
.ndo_bridge_setlink = ice_bridge_setlink,
.ndo_fdb_add = ice_fdb_add,
.ndo_fdb_del = ice_fdb_del,
-#ifdef CONFIG_RFS_ACCEL
- .ndo_rx_flow_steer = ice_rx_flow_steer,
-#endif
.ndo_tx_timeout = ice_tx_timeout,
.ndo_bpf = ice_xdp,
.ndo_xdp_xmit = ice_xdp_xmit,
.ndo_xsk_wakeup = ice_xsk_wakeup,
+ SET_RFS_ACCEL_OPS(ice_rx_flow_steer)
};
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
index b6f0376e42f4..1459dced175e 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
@@ -406,10 +406,7 @@ enum ixgbe_ring_f_enum {
RING_F_VMDQ, /* SR-IOV uses the same ring feature */
RING_F_RSS,
RING_F_FDIR,
-#ifdef IXGBE_FCOE
RING_F_FCOE,
-#endif /* IXGBE_FCOE */
-
RING_F_ARRAY_SIZE /* must be last in enum set */
};
@@ -567,10 +564,8 @@ static inline u16 ixgbe_desc_unused(struct ixgbe_ring *ring)
(&(((struct ixgbe_adv_tx_context_desc *)((R)->desc))[i]))
#define IXGBE_MAX_JUMBO_FRAME_SIZE 9728 /* Maximum Supported Size 9.5KB */
-#ifdef IXGBE_FCOE
/* Use 3K as the baby jumbo frame size for FCoE */
#define IXGBE_FCOE_JUMBO_FRAME_SIZE 3072
-#endif /* IXGBE_FCOE */
#define OTHER_VECTOR 1
#define NON_Q_VECTORS (OTHER_VECTOR)
@@ -980,7 +975,6 @@ void ixgbe_do_reset(struct net_device *netdev);
void ixgbe_sysfs_exit(struct ixgbe_adapter *adapter);
int ixgbe_sysfs_init(struct ixgbe_adapter *adapter);
#endif /* CONFIG_IXGBE_HWMON */
-#ifdef IXGBE_FCOE
void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter);
int ixgbe_fso(struct ixgbe_ring *tx_ring, struct ixgbe_tx_buffer *first,
u8 *hdr_len);
@@ -999,7 +993,6 @@ int ixgbe_fcoe_get_wwn(struct net_device *netdev, u64 *wwn, int type);
int ixgbe_fcoe_get_hbainfo(struct net_device *netdev,
struct netdev_fcoe_hbainfo *info);
u8 ixgbe_fcoe_get_tc(struct ixgbe_adapter *adapter);
-#endif /* IXGBE_FCOE */
#ifdef CONFIG_DEBUG_FS
void ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter);
void ixgbe_dbg_adapter_exit(struct ixgbe_adapter *adapter);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index bd541527c8c7..8c9265a04dc6 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -10416,14 +10416,11 @@ static const struct net_device_ops ixgbe_netdev_ops = {
.ndo_setup_tc = __ixgbe_setup_tc,
#ifdef IXGBE_FCOE
.ndo_select_queue = ixgbe_select_queue,
- .ndo_fcoe_ddp_setup = ixgbe_fcoe_ddp_get,
- .ndo_fcoe_ddp_target = ixgbe_fcoe_ddp_target,
- .ndo_fcoe_ddp_done = ixgbe_fcoe_ddp_put,
- .ndo_fcoe_enable = ixgbe_fcoe_enable,
- .ndo_fcoe_disable = ixgbe_fcoe_disable,
- .ndo_fcoe_get_wwn = ixgbe_fcoe_get_wwn,
- .ndo_fcoe_get_hbainfo = ixgbe_fcoe_get_hbainfo,
#endif /* IXGBE_FCOE */
+ SET_FCOE_OPS(ixgbe_fcoe_enable, ixgbe_fcoe_disable,
+ ixgbe_fcoe_ddp_target, ixgbe_fcoe_ddp_get,
+ ixgbe_fcoe_ddp_put, ixgbe_fcoe_get_hbainfo)
+ SET_FCOE_GET_WWN_OPS(ixgbe_fcoe_get_wwn)
.ndo_set_features = ixgbe_set_features,
.ndo_fix_features = ixgbe_fix_features,
.ndo_fdb_add = ixgbe_ndo_fdb_add,
@@ -10761,9 +10758,6 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
u8 part_str[IXGBE_PBANUM_LENGTH];
int i, err, expected_gts;
bool disable_dev = false;
-#ifdef IXGBE_FCOE
- u16 device_caps;
-#endif
u32 eec;
/* Catch broken hardware that put the wrong VF device ID in
@@ -11012,9 +11006,10 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
netdev->dcbnl_ops = &ixgbe_dcbnl_ops;
#endif
-#ifdef IXGBE_FCOE
- if (adapter->flags & IXGBE_FLAG_FCOE_CAPABLE) {
+ if (IS_ENABLED(CONFIG_FCOE) &&
+ adapter->flags & IXGBE_FLAG_FCOE_CAPABLE) {
unsigned int fcoe_l;
+ u16 device_caps;
if (hw->mac.ops.get_device_caps) {
hw->mac.ops.get_device_caps(hw, &device_caps);
@@ -11033,7 +11028,7 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
NETIF_F_FCOE_CRC |
NETIF_F_FCOE_MTU;
}
-#endif /* IXGBE_FCOE */
+
if (adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE)
netdev->hw_features |= NETIF_F_LRO;
if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
index 7299a830f6e4..683a68a43bd2 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
@@ -494,12 +494,10 @@ static int ixgbe_set_vf_lpe(struct ixgbe_adapter *adapter, u32 max_frame, u32 vf
u32 reg_offset, vf_shift, vfre;
s32 err = 0;
-#ifdef CONFIG_FCOE
- if (dev->features & NETIF_F_FCOE_MTU)
+ if (IS_ENABLED(CONFIG_FCOE) && dev->features & NETIF_F_FCOE_MTU)
pf_max_frame = max_t(int, pf_max_frame,
IXGBE_FCOE_JUMBO_FRAME_SIZE);
-#endif /* CONFIG_FCOE */
switch (adapter->vfinfo[vf].vf_api) {
case ixgbe_mbox_api_11:
case ixgbe_mbox_api_12:
@@ -856,11 +854,9 @@ static void ixgbe_set_vf_rx_tx(struct ixgbe_adapter *adapter, int vf)
struct net_device *dev = adapter->netdev;
int pf_max_frame = dev->mtu + ETH_HLEN;
-#if IS_ENABLED(CONFIG_FCOE)
- if (dev->features & NETIF_F_FCOE_MTU)
+ if (IS_ENABLED(CONFIG_FCOE) && dev->features & NETIF_F_FCOE_MTU)
pf_max_frame = max_t(int, pf_max_frame,
IXGBE_FCOE_JUMBO_FRAME_SIZE);
-#endif /* CONFIG_FCOE */
if (pf_max_frame > ETH_FRAME_LEN)
reg_req_rx = reg_cur_rx & ~(1 << vf_shift);
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 118c40258d07..22ae80271e57 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -869,7 +869,6 @@ struct netdev_tc_txq {
u16 offset;
};
-#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
/*
* This structure is to hold information about the device
* configured to run FCoE protocol stack.
@@ -884,7 +883,6 @@ struct netdev_fcoe_hbainfo {
char model[256];
char model_description[256];
};
-#endif
#define MAX_PHYS_ITEM_ID_LEN 32
@@ -1549,9 +1547,9 @@ struct net_device_ops {
struct netdev_fcoe_hbainfo *hbainfo);
#endif
-#if IS_ENABLED(CONFIG_LIBFCOE)
#define NETDEV_FCOE_WWNN 0
#define NETDEV_FCOE_WWPN 1
+#if IS_ENABLED(CONFIG_LIBFCOE)
int (*ndo_fcoe_get_wwn)(struct net_device *dev,
u64 *wwn, int type);
#endif
@@ -1681,6 +1679,36 @@ struct net_device_ops {
struct netlink_ext_ack *extack);
};
+#define rfs_accel_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_RFS_ACCEL), (_ptr))
+
+#if IS_ENABLED(CONFIG_RFS_ACCEL)
+#define SET_RFS_ACCEL_OPS(flow_fn) \
+ .ndo_rx_flow_steer = rfs_accel_ptr(flow_fn),
+#else
+#define SET_RFS_ACCEL_OPS(flow_fn)
+#endif
+
+#define fcoe_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_FCOE), (_ptr))
+#if IS_ENABLED(CONFIG_FCOE)
+#define SET_FCOE_OPS(enable_fn, disable_fn, ddp_target_fn, ddp_setup_fn, ddp_done_fn, get_hbainfo_fn) \
+ .ndo_fcoe_enable = fcoe_ptr(enable_fn), \
+ .ndo_fcoe_disable = fcoe_ptr(disable_fn), \
+ .ndo_fcoe_ddp_target = fcoe_ptr(ddp_target_fn), \
+ .ndo_fcoe_ddp_setup = fcoe_ptr(ddp_setup_fn), \
+ .ndo_fcoe_ddp_done = fcoe_ptr(ddp_done_fn), \
+ .ndo_fcoe_get_hbainfo = fcoe_ptr(get_hbainfo_fn),
+#else
+#define SET_FCOE_OPS(enable_fn, disable_fn, ddp_setup_fn, ddp_done_fn, ddp_target_fn, get_hbainfo_fn)
+#endif /* CONFIG_FCOE */
+
+#define fcoe_wwn_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_LIBFCOE), (_ptr))
+#if IS_ENABLED(CONFIG_LIBFCOE)
+#define SET_FCOE_GET_WWN_OPS(get_wwn_fn) \
+ .ndo_fcoe_get_wwn = fcoe_wwn_ptr(get_wwn_fn),
+#else
+#define SET_FCOE_GET_WWN_OPS(get_wwn_fn)
+#endif /* CONFIG_LIBFCOE */
+
/**
* enum netdev_priv_flags - &struct net_device priv_flags
*
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 407b2335f091..7b5cb64a839a 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -411,7 +411,6 @@ static int vlan_dev_neigh_setup(struct net_device *dev, struct neigh_parms *pa)
return err;
}
-#if IS_ENABLED(CONFIG_FCOE)
static int vlan_dev_fcoe_ddp_setup(struct net_device *dev, u16 xid,
struct scatterlist *sgl, unsigned int sgc)
{
@@ -471,9 +470,7 @@ static int vlan_dev_fcoe_ddp_target(struct net_device *dev, u16 xid,
return rc;
}
-#endif
-#ifdef NETDEV_FCOE_WWNN
static int vlan_dev_fcoe_get_wwn(struct net_device *dev, u64 *wwn, int type)
{
struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
@@ -484,7 +481,6 @@ static int vlan_dev_fcoe_get_wwn(struct net_device *dev, u64 *wwn, int type)
rc = ops->ndo_fcoe_get_wwn(real_dev, wwn, type);
return rc;
}
-#endif
static void vlan_dev_change_rx_flags(struct net_device *dev, int change)
{
@@ -1065,16 +1061,10 @@ static const struct net_device_ops vlan_netdev_ops = {
.ndo_eth_ioctl = vlan_dev_ioctl,
.ndo_neigh_setup = vlan_dev_neigh_setup,
.ndo_get_stats64 = vlan_dev_get_stats64,
-#if IS_ENABLED(CONFIG_FCOE)
- .ndo_fcoe_ddp_setup = vlan_dev_fcoe_ddp_setup,
- .ndo_fcoe_ddp_done = vlan_dev_fcoe_ddp_done,
- .ndo_fcoe_enable = vlan_dev_fcoe_enable,
- .ndo_fcoe_disable = vlan_dev_fcoe_disable,
- .ndo_fcoe_ddp_target = vlan_dev_fcoe_ddp_target,
-#endif
-#ifdef NETDEV_FCOE_WWNN
- .ndo_fcoe_get_wwn = vlan_dev_fcoe_get_wwn,
-#endif
+ SET_FCOE_OPS(vlan_dev_fcoe_enable, vlan_dev_fcoe_disable,
+ vlan_dev_fcoe_ddp_target, vlan_dev_fcoe_ddp_setup,
+ vlan_dev_fcoe_ddp_done, NULL)
+ SET_FCOE_GET_WWN_OPS(vlan_dev_fcoe_get_wwn)
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = vlan_dev_poll_controller,
.ndo_netpoll_setup = vlan_dev_netpoll_setup,
--
2.39.3
Powered by blists - more mailing lists