Skip to content

Commit 28cb2d1

Browse files
Zhang ShengjuJeff Kirsher
authored andcommitted
igb: add function to get maximum RSS queues
This patch adds a new function igb_get_max_rss_queues() to get maximum RSS queues, this will reduce duplicate code and facilitate future maintenance. Signed-off-by: Zhang Shengju <[email protected]> Tested-by: Aaron Brown <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 177132d commit 28cb2d1

File tree

3 files changed

+12
-33
lines changed

3 files changed

+12
-33
lines changed

drivers/net/ethernet/intel/igb/igb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,7 @@ void igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector, void *va,
690690
int igb_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr);
691691
int igb_ptp_get_ts_config(struct net_device *netdev, struct ifreq *ifr);
692692
void igb_set_flag_queue_pairs(struct igb_adapter *, const u32);
693+
unsigned int igb_get_max_rss_queues(struct igb_adapter *);
693694
#ifdef CONFIG_IGB_HWMON
694695
void igb_sysfs_exit(struct igb_adapter *adapter);
695696
int igb_sysfs_init(struct igb_adapter *adapter);

drivers/net/ethernet/intel/igb/igb_ethtool.c

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3338,37 +3338,7 @@ static int igb_set_rxfh(struct net_device *netdev, const u32 *indir,
33383338

33393339
static unsigned int igb_max_channels(struct igb_adapter *adapter)
33403340
{
3341-
struct e1000_hw *hw = &adapter->hw;
3342-
unsigned int max_combined = 0;
3343-
3344-
switch (hw->mac.type) {
3345-
case e1000_i211:
3346-
max_combined = IGB_MAX_RX_QUEUES_I211;
3347-
break;
3348-
case e1000_82575:
3349-
case e1000_i210:
3350-
max_combined = IGB_MAX_RX_QUEUES_82575;
3351-
break;
3352-
case e1000_i350:
3353-
if (!!adapter->vfs_allocated_count) {
3354-
max_combined = 1;
3355-
break;
3356-
}
3357-
/* fall through */
3358-
case e1000_82576:
3359-
if (!!adapter->vfs_allocated_count) {
3360-
max_combined = 2;
3361-
break;
3362-
}
3363-
/* fall through */
3364-
case e1000_82580:
3365-
case e1000_i354:
3366-
default:
3367-
max_combined = IGB_MAX_RX_QUEUES;
3368-
break;
3369-
}
3370-
3371-
return max_combined;
3341+
return igb_get_max_rss_queues(adapter);
33723342
}
33733343

33743344
static void igb_get_channels(struct net_device *netdev,

drivers/net/ethernet/intel/igb/igb_main.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3373,10 +3373,10 @@ static void igb_probe_vfs(struct igb_adapter *adapter)
33733373
#endif /* CONFIG_PCI_IOV */
33743374
}
33753375

3376-
static void igb_init_queue_configuration(struct igb_adapter *adapter)
3376+
unsigned int igb_get_max_rss_queues(struct igb_adapter *adapter)
33773377
{
33783378
struct e1000_hw *hw = &adapter->hw;
3379-
u32 max_rss_queues;
3379+
unsigned int max_rss_queues;
33803380

33813381
/* Determine the maximum number of RSS queues supported. */
33823382
switch (hw->mac.type) {
@@ -3407,6 +3407,14 @@ static void igb_init_queue_configuration(struct igb_adapter *adapter)
34073407
break;
34083408
}
34093409

3410+
return max_rss_queues;
3411+
}
3412+
3413+
static void igb_init_queue_configuration(struct igb_adapter *adapter)
3414+
{
3415+
u32 max_rss_queues;
3416+
3417+
max_rss_queues = igb_get_max_rss_queues(adapter);
34103418
adapter->rss_queues = min_t(u32, max_rss_queues, num_online_cpus());
34113419

34123420
igb_set_flag_queue_pairs(adapter, max_rss_queues);

0 commit comments

Comments
 (0)