Skip to content

Commit 3d66f21

Browse files
iveceraanguy11
authored andcommitted
iavf: Remove queue tracking fields from iavf_adminq_ring
Fields 'head', 'tail', 'len', 'bah' and 'bal' in iavf_adminq_ring are used to store register offsets. These offsets are initialized and remains constant so there is no need to store them in the iavf_adminq_ring structure. Remove these fields from iavf_adminq_ring and use register offset constants instead. Remove iavf_adminq_init_regs() that originally stores these constants into these fields. Finally improve iavf_check_asq_alive() that assumes that non-zero value of hw->aq.asq.len indicates fully initialized AdminQ send queue. Replace it by check for non-zero value of field hw->aq.asq.count that is non-zero when the sending queue is initialized and is zeroed during shutdown of the queue. Signed-off-by: Ivan Vecera <ivecera@redhat.com> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com> Reviewed-by: Simon Horman <horms@kernel.org> Tested-by: Rafal Romanowski <rafal.romanowski@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 4a95ce2 commit 3d66f21

File tree

4 files changed

+39
-70
lines changed

4 files changed

+39
-70
lines changed

drivers/net/ethernet/intel/iavf/iavf_adminq.c

Lines changed: 31 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,6 @@
77
#include "iavf_adminq.h"
88
#include "iavf_prototype.h"
99

10-
/**
11-
* iavf_adminq_init_regs - Initialize AdminQ registers
12-
* @hw: pointer to the hardware structure
13-
*
14-
* This assumes the alloc_asq and alloc_arq functions have already been called
15-
**/
16-
static void iavf_adminq_init_regs(struct iavf_hw *hw)
17-
{
18-
/* set head and tail registers in our local struct */
19-
hw->aq.asq.tail = IAVF_VF_ATQT1;
20-
hw->aq.asq.head = IAVF_VF_ATQH1;
21-
hw->aq.asq.len = IAVF_VF_ATQLEN1;
22-
hw->aq.asq.bal = IAVF_VF_ATQBAL1;
23-
hw->aq.asq.bah = IAVF_VF_ATQBAH1;
24-
hw->aq.arq.tail = IAVF_VF_ARQT1;
25-
hw->aq.arq.head = IAVF_VF_ARQH1;
26-
hw->aq.arq.len = IAVF_VF_ARQLEN1;
27-
hw->aq.arq.bal = IAVF_VF_ARQBAL1;
28-
hw->aq.arq.bah = IAVF_VF_ARQBAH1;
29-
}
30-
3110
/**
3211
* iavf_alloc_adminq_asq_ring - Allocate Admin Queue send rings
3312
* @hw: pointer to the hardware structure
@@ -259,17 +238,17 @@ static enum iavf_status iavf_config_asq_regs(struct iavf_hw *hw)
259238
u32 reg = 0;
260239

261240
/* Clear Head and Tail */
262-
wr32(hw, hw->aq.asq.head, 0);
263-
wr32(hw, hw->aq.asq.tail, 0);
241+
wr32(hw, IAVF_VF_ATQH1, 0);
242+
wr32(hw, IAVF_VF_ATQT1, 0);
264243

265244
/* set starting point */
266-
wr32(hw, hw->aq.asq.len, (hw->aq.num_asq_entries |
245+
wr32(hw, IAVF_VF_ATQLEN1, (hw->aq.num_asq_entries |
267246
IAVF_VF_ATQLEN1_ATQENABLE_MASK));
268-
wr32(hw, hw->aq.asq.bal, lower_32_bits(hw->aq.asq.desc_buf.pa));
269-
wr32(hw, hw->aq.asq.bah, upper_32_bits(hw->aq.asq.desc_buf.pa));
247+
wr32(hw, IAVF_VF_ATQBAL1, lower_32_bits(hw->aq.asq.desc_buf.pa));
248+
wr32(hw, IAVF_VF_ATQBAH1, upper_32_bits(hw->aq.asq.desc_buf.pa));
270249

271250
/* Check one register to verify that config was applied */
272-
reg = rd32(hw, hw->aq.asq.bal);
251+
reg = rd32(hw, IAVF_VF_ATQBAL1);
273252
if (reg != lower_32_bits(hw->aq.asq.desc_buf.pa))
274253
ret_code = IAVF_ERR_ADMIN_QUEUE_ERROR;
275254

@@ -288,20 +267,20 @@ static enum iavf_status iavf_config_arq_regs(struct iavf_hw *hw)
288267
u32 reg = 0;
289268

290269
/* Clear Head and Tail */
291-
wr32(hw, hw->aq.arq.head, 0);
292-
wr32(hw, hw->aq.arq.tail, 0);
270+
wr32(hw, IAVF_VF_ARQH1, 0);
271+
wr32(hw, IAVF_VF_ARQT1, 0);
293272

294273
/* set starting point */
295-
wr32(hw, hw->aq.arq.len, (hw->aq.num_arq_entries |
274+
wr32(hw, IAVF_VF_ARQLEN1, (hw->aq.num_arq_entries |
296275
IAVF_VF_ARQLEN1_ARQENABLE_MASK));
297-
wr32(hw, hw->aq.arq.bal, lower_32_bits(hw->aq.arq.desc_buf.pa));
298-
wr32(hw, hw->aq.arq.bah, upper_32_bits(hw->aq.arq.desc_buf.pa));
276+
wr32(hw, IAVF_VF_ARQBAL1, lower_32_bits(hw->aq.arq.desc_buf.pa));
277+
wr32(hw, IAVF_VF_ARQBAH1, upper_32_bits(hw->aq.arq.desc_buf.pa));
299278

300279
/* Update tail in the HW to post pre-allocated buffers */
301-
wr32(hw, hw->aq.arq.tail, hw->aq.num_arq_entries - 1);
280+
wr32(hw, IAVF_VF_ARQT1, hw->aq.num_arq_entries - 1);
302281

303282
/* Check one register to verify that config was applied */
304-
reg = rd32(hw, hw->aq.arq.bal);
283+
reg = rd32(hw, IAVF_VF_ARQBAL1);
305284
if (reg != lower_32_bits(hw->aq.arq.desc_buf.pa))
306285
ret_code = IAVF_ERR_ADMIN_QUEUE_ERROR;
307286

@@ -455,11 +434,11 @@ static enum iavf_status iavf_shutdown_asq(struct iavf_hw *hw)
455434
}
456435

457436
/* Stop firmware AdminQ processing */
458-
wr32(hw, hw->aq.asq.head, 0);
459-
wr32(hw, hw->aq.asq.tail, 0);
460-
wr32(hw, hw->aq.asq.len, 0);
461-
wr32(hw, hw->aq.asq.bal, 0);
462-
wr32(hw, hw->aq.asq.bah, 0);
437+
wr32(hw, IAVF_VF_ATQH1, 0);
438+
wr32(hw, IAVF_VF_ATQT1, 0);
439+
wr32(hw, IAVF_VF_ATQLEN1, 0);
440+
wr32(hw, IAVF_VF_ATQBAL1, 0);
441+
wr32(hw, IAVF_VF_ATQBAH1, 0);
463442

464443
hw->aq.asq.count = 0; /* to indicate uninitialized queue */
465444

@@ -489,11 +468,11 @@ static enum iavf_status iavf_shutdown_arq(struct iavf_hw *hw)
489468
}
490469

491470
/* Stop firmware AdminQ processing */
492-
wr32(hw, hw->aq.arq.head, 0);
493-
wr32(hw, hw->aq.arq.tail, 0);
494-
wr32(hw, hw->aq.arq.len, 0);
495-
wr32(hw, hw->aq.arq.bal, 0);
496-
wr32(hw, hw->aq.arq.bah, 0);
471+
wr32(hw, IAVF_VF_ARQH1, 0);
472+
wr32(hw, IAVF_VF_ARQT1, 0);
473+
wr32(hw, IAVF_VF_ARQLEN1, 0);
474+
wr32(hw, IAVF_VF_ARQBAL1, 0);
475+
wr32(hw, IAVF_VF_ARQBAH1, 0);
497476

498477
hw->aq.arq.count = 0; /* to indicate uninitialized queue */
499478

@@ -529,9 +508,6 @@ enum iavf_status iavf_init_adminq(struct iavf_hw *hw)
529508
goto init_adminq_exit;
530509
}
531510

532-
/* Set up register offsets */
533-
iavf_adminq_init_regs(hw);
534-
535511
/* setup ASQ command write back timeout */
536512
hw->aq.asq_cmd_timeout = IAVF_ASQ_CMD_TIMEOUT;
537513

@@ -587,9 +563,9 @@ static u16 iavf_clean_asq(struct iavf_hw *hw)
587563

588564
desc = IAVF_ADMINQ_DESC(*asq, ntc);
589565
details = IAVF_ADMINQ_DETAILS(*asq, ntc);
590-
while (rd32(hw, hw->aq.asq.head) != ntc) {
566+
while (rd32(hw, IAVF_VF_ATQH1) != ntc) {
591567
iavf_debug(hw, IAVF_DEBUG_AQ_MESSAGE,
592-
"ntc %d head %d.\n", ntc, rd32(hw, hw->aq.asq.head));
568+
"ntc %d head %d.\n", ntc, rd32(hw, IAVF_VF_ATQH1));
593569

594570
if (details->callback) {
595571
IAVF_ADMINQ_CALLBACK cb_func =
@@ -624,7 +600,7 @@ bool iavf_asq_done(struct iavf_hw *hw)
624600
/* AQ designers suggest use of head for better
625601
* timing reliability than DD bit
626602
*/
627-
return rd32(hw, hw->aq.asq.head) == hw->aq.asq.next_to_use;
603+
return rd32(hw, IAVF_VF_ATQH1) == hw->aq.asq.next_to_use;
628604
}
629605

630606
/**
@@ -663,7 +639,7 @@ enum iavf_status iavf_asq_send_command(struct iavf_hw *hw,
663639

664640
hw->aq.asq_last_status = IAVF_AQ_RC_OK;
665641

666-
val = rd32(hw, hw->aq.asq.head);
642+
val = rd32(hw, IAVF_VF_ATQH1);
667643
if (val >= hw->aq.num_asq_entries) {
668644
iavf_debug(hw, IAVF_DEBUG_AQ_MESSAGE,
669645
"AQTX: head overrun at %d\n", val);
@@ -755,7 +731,7 @@ enum iavf_status iavf_asq_send_command(struct iavf_hw *hw,
755731
if (hw->aq.asq.next_to_use == hw->aq.asq.count)
756732
hw->aq.asq.next_to_use = 0;
757733
if (!details->postpone)
758-
wr32(hw, hw->aq.asq.tail, hw->aq.asq.next_to_use);
734+
wr32(hw, IAVF_VF_ATQT1, hw->aq.asq.next_to_use);
759735

760736
/* if cmd_details are not defined or async flag is not set,
761737
* we need to wait for desc write back
@@ -810,7 +786,7 @@ enum iavf_status iavf_asq_send_command(struct iavf_hw *hw,
810786
/* update the error if time out occurred */
811787
if ((!cmd_completed) &&
812788
(!details->async && !details->postpone)) {
813-
if (rd32(hw, hw->aq.asq.len) & IAVF_VF_ATQLEN1_ATQCRIT_MASK) {
789+
if (rd32(hw, IAVF_VF_ATQLEN1) & IAVF_VF_ATQLEN1_ATQCRIT_MASK) {
814790
iavf_debug(hw, IAVF_DEBUG_AQ_MESSAGE,
815791
"AQTX: AQ Critical error.\n");
816792
status = IAVF_ERR_ADMIN_QUEUE_CRITICAL_ERROR;
@@ -878,7 +854,7 @@ enum iavf_status iavf_clean_arq_element(struct iavf_hw *hw,
878854
}
879855

880856
/* set next_to_use to head */
881-
ntu = rd32(hw, hw->aq.arq.head) & IAVF_VF_ARQH1_ARQH_MASK;
857+
ntu = rd32(hw, IAVF_VF_ARQH1) & IAVF_VF_ARQH1_ARQH_MASK;
882858
if (ntu == ntc) {
883859
/* nothing to do - shouldn't need to update ring's values */
884860
ret_code = IAVF_ERR_ADMIN_QUEUE_NO_WORK;
@@ -926,7 +902,7 @@ enum iavf_status iavf_clean_arq_element(struct iavf_hw *hw,
926902
desc->params.external.addr_low = cpu_to_le32(lower_32_bits(bi->pa));
927903

928904
/* set tail = the last cleaned desc index. */
929-
wr32(hw, hw->aq.arq.tail, ntc);
905+
wr32(hw, IAVF_VF_ARQT1, ntc);
930906
/* ntc is updated to tail + 1 */
931907
ntc++;
932908
if (ntc == hw->aq.num_arq_entries)

drivers/net/ethernet/intel/iavf/iavf_adminq.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ struct iavf_adminq_ring {
2929
/* used for interrupt processing */
3030
u16 next_to_use;
3131
u16 next_to_clean;
32-
33-
/* used for queue tracking */
34-
u32 head;
35-
u32 tail;
36-
u32 len;
37-
u32 bah;
38-
u32 bal;
3932
};
4033

4134
/* ASQ transaction details */

drivers/net/ethernet/intel/iavf/iavf_common.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,11 @@ void iavf_debug_aq(struct iavf_hw *hw, enum iavf_debug_mask mask, void *desc,
279279
**/
280280
bool iavf_check_asq_alive(struct iavf_hw *hw)
281281
{
282-
if (hw->aq.asq.len)
283-
return !!(rd32(hw, hw->aq.asq.len) &
284-
IAVF_VF_ATQLEN1_ATQENABLE_MASK);
285-
else
282+
/* Check if the queue is initialized */
283+
if (!hw->aq.asq.count)
286284
return false;
285+
286+
return !!(rd32(hw, IAVF_VF_ATQLEN1) & IAVF_VF_ATQLEN1_ATQENABLE_MASK);
287287
}
288288

289289
/**

drivers/net/ethernet/intel/iavf/iavf_main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3253,7 +3253,7 @@ static void iavf_adminq_task(struct work_struct *work)
32533253
goto freedom;
32543254

32553255
/* check for error indications */
3256-
val = rd32(hw, hw->aq.arq.len);
3256+
val = rd32(hw, IAVF_VF_ARQLEN1);
32573257
if (val == 0xdeadbeef || val == 0xffffffff) /* device in reset */
32583258
goto freedom;
32593259
oldval = val;
@@ -3270,9 +3270,9 @@ static void iavf_adminq_task(struct work_struct *work)
32703270
val &= ~IAVF_VF_ARQLEN1_ARQCRIT_MASK;
32713271
}
32723272
if (oldval != val)
3273-
wr32(hw, hw->aq.arq.len, val);
3273+
wr32(hw, IAVF_VF_ARQLEN1, val);
32743274

3275-
val = rd32(hw, hw->aq.asq.len);
3275+
val = rd32(hw, IAVF_VF_ATQLEN1);
32763276
oldval = val;
32773277
if (val & IAVF_VF_ATQLEN1_ATQVFE_MASK) {
32783278
dev_info(&adapter->pdev->dev, "ASQ VF Error detected\n");
@@ -3287,7 +3287,7 @@ static void iavf_adminq_task(struct work_struct *work)
32873287
val &= ~IAVF_VF_ATQLEN1_ATQCRIT_MASK;
32883288
}
32893289
if (oldval != val)
3290-
wr32(hw, hw->aq.asq.len, val);
3290+
wr32(hw, IAVF_VF_ATQLEN1, val);
32913291

32923292
freedom:
32933293
kfree(event.msg_buf);

0 commit comments

Comments
 (0)