Skip to content

Commit 4a95ce2

Browse files
iveceraanguy11
authored andcommitted
i40e: Remove queue tracking fields from i40e_adminq_ring
Fields 'head', 'tail', 'len', 'bah' and 'bal' in i40e_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 i40e_adminq_ring structure. Remove these fields from i40e_adminq_ring and use register offset constants instead. Remove i40e_adminq_init_regs() that originally stores these constants into these fields. Finally improve i40e_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> Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 64c0aad commit 4a95ce2

File tree

4 files changed

+39
-70
lines changed

4 files changed

+39
-70
lines changed

drivers/net/ethernet/intel/i40e/i40e_adminq.c

Lines changed: 31 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,6 @@
88

99
static void i40e_resume_aq(struct i40e_hw *hw);
1010

11-
/**
12-
* i40e_adminq_init_regs - Initialize AdminQ registers
13-
* @hw: pointer to the hardware structure
14-
*
15-
* This assumes the alloc_asq and alloc_arq functions have already been called
16-
**/
17-
static void i40e_adminq_init_regs(struct i40e_hw *hw)
18-
{
19-
/* set head and tail registers in our local struct */
20-
hw->aq.asq.tail = I40E_PF_ATQT;
21-
hw->aq.asq.head = I40E_PF_ATQH;
22-
hw->aq.asq.len = I40E_PF_ATQLEN;
23-
hw->aq.asq.bal = I40E_PF_ATQBAL;
24-
hw->aq.asq.bah = I40E_PF_ATQBAH;
25-
hw->aq.arq.tail = I40E_PF_ARQT;
26-
hw->aq.arq.head = I40E_PF_ARQH;
27-
hw->aq.arq.len = I40E_PF_ARQLEN;
28-
hw->aq.arq.bal = I40E_PF_ARQBAL;
29-
hw->aq.arq.bah = I40E_PF_ARQBAH;
30-
}
31-
3211
/**
3312
* i40e_alloc_adminq_asq_ring - Allocate Admin Queue send rings
3413
* @hw: pointer to the hardware structure
@@ -254,17 +233,17 @@ static int i40e_config_asq_regs(struct i40e_hw *hw)
254233
u32 reg = 0;
255234

256235
/* Clear Head and Tail */
257-
wr32(hw, hw->aq.asq.head, 0);
258-
wr32(hw, hw->aq.asq.tail, 0);
236+
wr32(hw, I40E_PF_ATQH, 0);
237+
wr32(hw, I40E_PF_ATQT, 0);
259238

260239
/* set starting point */
261-
wr32(hw, hw->aq.asq.len, (hw->aq.num_asq_entries |
240+
wr32(hw, I40E_PF_ATQLEN, (hw->aq.num_asq_entries |
262241
I40E_PF_ATQLEN_ATQENABLE_MASK));
263-
wr32(hw, hw->aq.asq.bal, lower_32_bits(hw->aq.asq.desc_buf.pa));
264-
wr32(hw, hw->aq.asq.bah, upper_32_bits(hw->aq.asq.desc_buf.pa));
242+
wr32(hw, I40E_PF_ATQBAL, lower_32_bits(hw->aq.asq.desc_buf.pa));
243+
wr32(hw, I40E_PF_ATQBAH, upper_32_bits(hw->aq.asq.desc_buf.pa));
265244

266245
/* Check one register to verify that config was applied */
267-
reg = rd32(hw, hw->aq.asq.bal);
246+
reg = rd32(hw, I40E_PF_ATQBAL);
268247
if (reg != lower_32_bits(hw->aq.asq.desc_buf.pa))
269248
ret_code = -EIO;
270249

@@ -283,20 +262,20 @@ static int i40e_config_arq_regs(struct i40e_hw *hw)
283262
u32 reg = 0;
284263

285264
/* Clear Head and Tail */
286-
wr32(hw, hw->aq.arq.head, 0);
287-
wr32(hw, hw->aq.arq.tail, 0);
265+
wr32(hw, I40E_PF_ARQH, 0);
266+
wr32(hw, I40E_PF_ARQT, 0);
288267

289268
/* set starting point */
290-
wr32(hw, hw->aq.arq.len, (hw->aq.num_arq_entries |
269+
wr32(hw, I40E_PF_ARQLEN, (hw->aq.num_arq_entries |
291270
I40E_PF_ARQLEN_ARQENABLE_MASK));
292-
wr32(hw, hw->aq.arq.bal, lower_32_bits(hw->aq.arq.desc_buf.pa));
293-
wr32(hw, hw->aq.arq.bah, upper_32_bits(hw->aq.arq.desc_buf.pa));
271+
wr32(hw, I40E_PF_ARQBAL, lower_32_bits(hw->aq.arq.desc_buf.pa));
272+
wr32(hw, I40E_PF_ARQBAH, upper_32_bits(hw->aq.arq.desc_buf.pa));
294273

295274
/* Update tail in the HW to post pre-allocated buffers */
296-
wr32(hw, hw->aq.arq.tail, hw->aq.num_arq_entries - 1);
275+
wr32(hw, I40E_PF_ARQT, hw->aq.num_arq_entries - 1);
297276

298277
/* Check one register to verify that config was applied */
299-
reg = rd32(hw, hw->aq.arq.bal);
278+
reg = rd32(hw, I40E_PF_ARQBAL);
300279
if (reg != lower_32_bits(hw->aq.arq.desc_buf.pa))
301280
ret_code = -EIO;
302281

@@ -439,11 +418,11 @@ static int i40e_shutdown_asq(struct i40e_hw *hw)
439418
}
440419

441420
/* Stop firmware AdminQ processing */
442-
wr32(hw, hw->aq.asq.head, 0);
443-
wr32(hw, hw->aq.asq.tail, 0);
444-
wr32(hw, hw->aq.asq.len, 0);
445-
wr32(hw, hw->aq.asq.bal, 0);
446-
wr32(hw, hw->aq.asq.bah, 0);
421+
wr32(hw, I40E_PF_ATQH, 0);
422+
wr32(hw, I40E_PF_ATQT, 0);
423+
wr32(hw, I40E_PF_ATQLEN, 0);
424+
wr32(hw, I40E_PF_ATQBAL, 0);
425+
wr32(hw, I40E_PF_ATQBAH, 0);
447426

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

@@ -473,11 +452,11 @@ static int i40e_shutdown_arq(struct i40e_hw *hw)
473452
}
474453

475454
/* Stop firmware AdminQ processing */
476-
wr32(hw, hw->aq.arq.head, 0);
477-
wr32(hw, hw->aq.arq.tail, 0);
478-
wr32(hw, hw->aq.arq.len, 0);
479-
wr32(hw, hw->aq.arq.bal, 0);
480-
wr32(hw, hw->aq.arq.bah, 0);
455+
wr32(hw, I40E_PF_ARQH, 0);
456+
wr32(hw, I40E_PF_ARQT, 0);
457+
wr32(hw, I40E_PF_ARQLEN, 0);
458+
wr32(hw, I40E_PF_ARQBAL, 0);
459+
wr32(hw, I40E_PF_ARQBAH, 0);
481460

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

@@ -608,9 +587,6 @@ int i40e_init_adminq(struct i40e_hw *hw)
608587
goto init_adminq_exit;
609588
}
610589

611-
/* Set up register offsets */
612-
i40e_adminq_init_regs(hw);
613-
614590
/* setup ASQ command write back timeout */
615591
hw->aq.asq_cmd_timeout = I40E_ASQ_CMD_TIMEOUT;
616592

@@ -720,9 +696,9 @@ static u16 i40e_clean_asq(struct i40e_hw *hw)
720696

721697
desc = I40E_ADMINQ_DESC(*asq, ntc);
722698
details = I40E_ADMINQ_DETAILS(*asq, ntc);
723-
while (rd32(hw, hw->aq.asq.head) != ntc) {
699+
while (rd32(hw, I40E_PF_ATQH) != ntc) {
724700
i40e_debug(hw, I40E_DEBUG_AQ_COMMAND,
725-
"ntc %d head %d.\n", ntc, rd32(hw, hw->aq.asq.head));
701+
"ntc %d head %d.\n", ntc, rd32(hw, I40E_PF_ATQH));
726702

727703
if (details->callback) {
728704
I40E_ADMINQ_CALLBACK cb_func =
@@ -756,7 +732,7 @@ static bool i40e_asq_done(struct i40e_hw *hw)
756732
/* AQ designers suggest use of head for better
757733
* timing reliability than DD bit
758734
*/
759-
return rd32(hw, hw->aq.asq.head) == hw->aq.asq.next_to_use;
735+
return rd32(hw, I40E_PF_ATQH) == hw->aq.asq.next_to_use;
760736

761737
}
762738

@@ -797,7 +773,7 @@ i40e_asq_send_command_atomic_exec(struct i40e_hw *hw,
797773

798774
hw->aq.asq_last_status = I40E_AQ_RC_OK;
799775

800-
val = rd32(hw, hw->aq.asq.head);
776+
val = rd32(hw, I40E_PF_ATQH);
801777
if (val >= hw->aq.num_asq_entries) {
802778
i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE,
803779
"AQTX: head overrun at %d\n", val);
@@ -889,7 +865,7 @@ i40e_asq_send_command_atomic_exec(struct i40e_hw *hw,
889865
if (hw->aq.asq.next_to_use == hw->aq.asq.count)
890866
hw->aq.asq.next_to_use = 0;
891867
if (!details->postpone)
892-
wr32(hw, hw->aq.asq.tail, hw->aq.asq.next_to_use);
868+
wr32(hw, I40E_PF_ATQT, hw->aq.asq.next_to_use);
893869

894870
/* if cmd_details are not defined or async flag is not set,
895871
* we need to wait for desc write back
@@ -949,7 +925,7 @@ i40e_asq_send_command_atomic_exec(struct i40e_hw *hw,
949925
/* update the error if time out occurred */
950926
if ((!cmd_completed) &&
951927
(!details->async && !details->postpone)) {
952-
if (rd32(hw, hw->aq.asq.len) & I40E_GL_ATQLEN_ATQCRIT_MASK) {
928+
if (rd32(hw, I40E_PF_ATQLEN) & I40E_GL_ATQLEN_ATQCRIT_MASK) {
953929
i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE,
954930
"AQTX: AQ Critical error.\n");
955931
status = -EIO;
@@ -1103,7 +1079,7 @@ int i40e_clean_arq_element(struct i40e_hw *hw,
11031079
}
11041080

11051081
/* set next_to_use to head */
1106-
ntu = rd32(hw, hw->aq.arq.head) & I40E_PF_ARQH_ARQH_MASK;
1082+
ntu = rd32(hw, I40E_PF_ARQH) & I40E_PF_ARQH_ARQH_MASK;
11071083
if (ntu == ntc) {
11081084
/* nothing to do - shouldn't need to update ring's values */
11091085
ret_code = -EALREADY;
@@ -1151,7 +1127,7 @@ int i40e_clean_arq_element(struct i40e_hw *hw,
11511127
desc->params.external.addr_low = cpu_to_le32(lower_32_bits(bi->pa));
11521128

11531129
/* set tail = the last cleaned desc index. */
1154-
wr32(hw, hw->aq.arq.tail, ntc);
1130+
wr32(hw, I40E_PF_ARQT, ntc);
11551131
/* ntc is updated to tail + 1 */
11561132
ntc++;
11571133
if (ntc == hw->aq.num_arq_entries)

drivers/net/ethernet/intel/i40e/i40e_adminq.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ struct i40e_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/i40e/i40e_common.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,11 @@ void i40e_debug_aq(struct i40e_hw *hw, enum i40e_debug_mask mask, void *desc,
195195
**/
196196
bool i40e_check_asq_alive(struct i40e_hw *hw)
197197
{
198-
if (hw->aq.asq.len)
199-
return !!(rd32(hw, hw->aq.asq.len) &
200-
I40E_PF_ATQLEN_ATQENABLE_MASK);
201-
else
198+
/* Check if the queue is initialized */
199+
if (!hw->aq.asq.count)
202200
return false;
201+
202+
return !!(rd32(hw, I40E_PF_ATQLEN) & I40E_PF_ATQLEN_ATQENABLE_MASK);
203203
}
204204

205205
/**

drivers/net/ethernet/intel/i40e/i40e_main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10127,7 +10127,7 @@ static void i40e_clean_adminq_subtask(struct i40e_pf *pf)
1012710127
return;
1012810128

1012910129
/* check for error indications */
10130-
val = rd32(&pf->hw, pf->hw.aq.arq.len);
10130+
val = rd32(&pf->hw, I40E_PF_ARQLEN);
1013110131
oldval = val;
1013210132
if (val & I40E_PF_ARQLEN_ARQVFE_MASK) {
1013310133
if (hw->debug_mask & I40E_DEBUG_AQ)
@@ -10146,9 +10146,9 @@ static void i40e_clean_adminq_subtask(struct i40e_pf *pf)
1014610146
val &= ~I40E_PF_ARQLEN_ARQCRIT_MASK;
1014710147
}
1014810148
if (oldval != val)
10149-
wr32(&pf->hw, pf->hw.aq.arq.len, val);
10149+
wr32(&pf->hw, I40E_PF_ARQLEN, val);
1015010150

10151-
val = rd32(&pf->hw, pf->hw.aq.asq.len);
10151+
val = rd32(&pf->hw, I40E_PF_ATQLEN);
1015210152
oldval = val;
1015310153
if (val & I40E_PF_ATQLEN_ATQVFE_MASK) {
1015410154
if (pf->hw.debug_mask & I40E_DEBUG_AQ)
@@ -10166,7 +10166,7 @@ static void i40e_clean_adminq_subtask(struct i40e_pf *pf)
1016610166
val &= ~I40E_PF_ATQLEN_ATQCRIT_MASK;
1016710167
}
1016810168
if (oldval != val)
10169-
wr32(&pf->hw, pf->hw.aq.asq.len, val);
10169+
wr32(&pf->hw, I40E_PF_ATQLEN, val);
1017010170

1017110171
event.buf_len = I40E_MAX_AQ_BUF_SIZE;
1017210172
event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL);

0 commit comments

Comments
 (0)