Skip to content

Commit 79d97b8

Browse files
Michal Swiatkowskianguy11
authored andcommitted
ice: remove splitting MSI-X between features
With dynamic approach to alloc MSI-X there is no sense to statically split MSI-X between PF features. Splitting was also calculating needed MSI-X. Move this part to separate function and use as max value. Remove ICE_ESWITCH_MSIX, as there is no need for additional MSI-X for switchdev. Reviewed-by: Jacob Keller <[email protected]> Reviewed-by: Wojciech Drewek <[email protected]> Tested-by: Pucha Himasekhar Reddy <[email protected]> Signed-off-by: Michal Swiatkowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent b265725 commit 79d97b8

File tree

2 files changed

+16
-158
lines changed

2 files changed

+16
-158
lines changed

drivers/net/ethernet/intel/ice/ice.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@
9898
#define ICE_MIN_MSIX (ICE_MIN_LAN_TXRX_MSIX + ICE_MIN_LAN_OICR_MSIX)
9999
#define ICE_FDIR_MSIX 2
100100
#define ICE_RDMA_NUM_AEQ_MSIX 4
101-
#define ICE_MIN_RDMA_MSIX 2
102-
#define ICE_ESWITCH_MSIX 1
103101
#define ICE_NO_VSI 0xffff
104102
#define ICE_VSI_MAP_CONTIG 0
105103
#define ICE_VSI_MAP_SCATTER 1

drivers/net/ethernet/intel/ice/ice_irq.c

Lines changed: 16 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -84,155 +84,11 @@ static struct ice_irq_entry *ice_get_irq_res(struct ice_pf *pf, bool dyn_only)
8484
return entry;
8585
}
8686

87-
/**
88-
* ice_reduce_msix_usage - Reduce usage of MSI-X vectors
89-
* @pf: board private structure
90-
* @v_remain: number of remaining MSI-X vectors to be distributed
91-
*
92-
* Reduce the usage of MSI-X vectors when entire request cannot be fulfilled.
93-
* pf->num_lan_msix and pf->num_rdma_msix values are set based on number of
94-
* remaining vectors.
95-
*/
96-
static void ice_reduce_msix_usage(struct ice_pf *pf, int v_remain)
87+
static int ice_get_default_msix_amount(struct ice_pf *pf)
9788
{
98-
int v_rdma;
99-
100-
if (!ice_is_rdma_ena(pf)) {
101-
pf->num_lan_msix = v_remain;
102-
return;
103-
}
104-
105-
/* RDMA needs at least 1 interrupt in addition to AEQ MSIX */
106-
v_rdma = ICE_RDMA_NUM_AEQ_MSIX + 1;
107-
108-
if (v_remain < ICE_MIN_LAN_TXRX_MSIX + ICE_MIN_RDMA_MSIX) {
109-
dev_warn(ice_pf_to_dev(pf), "Not enough MSI-X vectors to support RDMA.\n");
110-
clear_bit(ICE_FLAG_RDMA_ENA, pf->flags);
111-
112-
pf->num_rdma_msix = 0;
113-
pf->num_lan_msix = ICE_MIN_LAN_TXRX_MSIX;
114-
} else if ((v_remain < ICE_MIN_LAN_TXRX_MSIX + v_rdma) ||
115-
(v_remain - v_rdma < v_rdma)) {
116-
/* Support minimum RDMA and give remaining vectors to LAN MSIX
117-
*/
118-
pf->num_rdma_msix = ICE_MIN_RDMA_MSIX;
119-
pf->num_lan_msix = v_remain - ICE_MIN_RDMA_MSIX;
120-
} else {
121-
/* Split remaining MSIX with RDMA after accounting for AEQ MSIX
122-
*/
123-
pf->num_rdma_msix = (v_remain - ICE_RDMA_NUM_AEQ_MSIX) / 2 +
124-
ICE_RDMA_NUM_AEQ_MSIX;
125-
pf->num_lan_msix = v_remain - pf->num_rdma_msix;
126-
}
127-
}
128-
129-
/**
130-
* ice_ena_msix_range - Request a range of MSIX vectors from the OS
131-
* @pf: board private structure
132-
*
133-
* Compute the number of MSIX vectors wanted and request from the OS. Adjust
134-
* device usage if there are not enough vectors. Return the number of vectors
135-
* reserved or negative on failure.
136-
*/
137-
static int ice_ena_msix_range(struct ice_pf *pf)
138-
{
139-
int num_cpus, hw_num_msix, v_other, v_wanted, v_actual;
140-
struct device *dev = ice_pf_to_dev(pf);
141-
int err;
142-
143-
hw_num_msix = pf->hw.func_caps.common_cap.num_msix_vectors;
144-
num_cpus = num_online_cpus();
145-
146-
/* LAN miscellaneous handler */
147-
v_other = ICE_MIN_LAN_OICR_MSIX;
148-
149-
/* Flow Director */
150-
if (test_bit(ICE_FLAG_FD_ENA, pf->flags))
151-
v_other += ICE_FDIR_MSIX;
152-
153-
/* switchdev */
154-
v_other += ICE_ESWITCH_MSIX;
155-
156-
v_wanted = v_other;
157-
158-
/* LAN traffic */
159-
pf->num_lan_msix = num_cpus;
160-
v_wanted += pf->num_lan_msix;
161-
162-
/* RDMA auxiliary driver */
163-
if (ice_is_rdma_ena(pf)) {
164-
pf->num_rdma_msix = num_cpus + ICE_RDMA_NUM_AEQ_MSIX;
165-
v_wanted += pf->num_rdma_msix;
166-
}
167-
168-
if (v_wanted > hw_num_msix) {
169-
int v_remain;
170-
171-
dev_warn(dev, "not enough device MSI-X vectors. wanted = %d, available = %d\n",
172-
v_wanted, hw_num_msix);
173-
174-
if (hw_num_msix < ICE_MIN_MSIX) {
175-
err = -ERANGE;
176-
goto exit_err;
177-
}
178-
179-
v_remain = hw_num_msix - v_other;
180-
if (v_remain < ICE_MIN_LAN_TXRX_MSIX) {
181-
v_other = ICE_MIN_MSIX - ICE_MIN_LAN_TXRX_MSIX;
182-
v_remain = ICE_MIN_LAN_TXRX_MSIX;
183-
}
184-
185-
ice_reduce_msix_usage(pf, v_remain);
186-
v_wanted = pf->num_lan_msix + pf->num_rdma_msix + v_other;
187-
188-
dev_notice(dev, "Reducing request to %d MSI-X vectors for LAN traffic.\n",
189-
pf->num_lan_msix);
190-
if (ice_is_rdma_ena(pf))
191-
dev_notice(dev, "Reducing request to %d MSI-X vectors for RDMA.\n",
192-
pf->num_rdma_msix);
193-
}
194-
195-
/* actually reserve the vectors */
196-
v_actual = pci_alloc_irq_vectors(pf->pdev, ICE_MIN_MSIX, v_wanted,
197-
PCI_IRQ_MSIX);
198-
if (v_actual < 0) {
199-
dev_err(dev, "unable to reserve MSI-X vectors\n");
200-
err = v_actual;
201-
goto exit_err;
202-
}
203-
204-
if (v_actual < v_wanted) {
205-
dev_warn(dev, "not enough OS MSI-X vectors. requested = %d, obtained = %d\n",
206-
v_wanted, v_actual);
207-
208-
if (v_actual < ICE_MIN_MSIX) {
209-
/* error if we can't get minimum vectors */
210-
pci_free_irq_vectors(pf->pdev);
211-
err = -ERANGE;
212-
goto exit_err;
213-
} else {
214-
int v_remain = v_actual - v_other;
215-
216-
if (v_remain < ICE_MIN_LAN_TXRX_MSIX)
217-
v_remain = ICE_MIN_LAN_TXRX_MSIX;
218-
219-
ice_reduce_msix_usage(pf, v_remain);
220-
221-
dev_notice(dev, "Enabled %d MSI-X vectors for LAN traffic.\n",
222-
pf->num_lan_msix);
223-
224-
if (ice_is_rdma_ena(pf))
225-
dev_notice(dev, "Enabled %d MSI-X vectors for RDMA.\n",
226-
pf->num_rdma_msix);
227-
}
228-
}
229-
230-
return v_actual;
231-
232-
exit_err:
233-
pf->num_rdma_msix = 0;
234-
pf->num_lan_msix = 0;
235-
return err;
89+
return ICE_MIN_LAN_OICR_MSIX + num_online_cpus() +
90+
(test_bit(ICE_FLAG_FD_ENA, pf->flags) ? ICE_FDIR_MSIX : 0) +
91+
(ice_is_rdma_ena(pf) ? num_online_cpus() + ICE_RDMA_NUM_AEQ_MSIX : 0);
23692
}
23793

23894
/**
@@ -259,17 +115,21 @@ int ice_init_interrupt_scheme(struct ice_pf *pf)
259115
pf->msix.min = ICE_MIN_MSIX;
260116

261117
if (!pf->msix.max)
262-
pf->msix.max = total_vectors / 2;
263-
264-
vectors = ice_ena_msix_range(pf);
118+
pf->msix.max = min(total_vectors,
119+
ice_get_default_msix_amount(pf));
265120

266-
if (vectors < 0)
267-
return -ENOMEM;
268-
269-
if (pci_msix_can_alloc_dyn(pf->pdev))
121+
if (pci_msix_can_alloc_dyn(pf->pdev)) {
122+
vectors = pf->msix.min;
270123
max_vectors = total_vectors;
271-
else
124+
} else {
125+
vectors = pf->msix.max;
272126
max_vectors = vectors;
127+
}
128+
129+
vectors = pci_alloc_irq_vectors(pf->pdev, pf->msix.min, vectors,
130+
PCI_IRQ_MSIX);
131+
if (vectors < pf->msix.min)
132+
return -ENOMEM;
273133

274134
ice_init_irq_tracker(pf, max_vectors, vectors);
275135

0 commit comments

Comments
 (0)