Skip to content

Commit 328947f

Browse files
Nithin Sujirdavem330
authored andcommitted
tg3: Make tg3_rings_reset() more concise
Simplify the rings reset function and increase readability by moving the control block disable code into separate functions. Signed-off-by: Nithin Nayak Sujir <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 32ba19e commit 328947f

File tree

1 file changed

+48
-33
lines changed
  • drivers/net/ethernet/broadcom

1 file changed

+48
-33
lines changed

drivers/net/ethernet/broadcom/tg3.c

Lines changed: 48 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9239,6 +9239,28 @@ static void __tg3_set_coalesce(struct tg3 *tp, struct ethtool_coalesce *ec)
92399239
}
92409240
}
92419241

9242+
/* tp->lock is held. */
9243+
static void tg3_tx_rcbs_disable(struct tg3 *tp)
9244+
{
9245+
u32 txrcb, limit;
9246+
9247+
/* Disable all transmit rings but the first. */
9248+
if (!tg3_flag(tp, 5705_PLUS))
9249+
limit = NIC_SRAM_SEND_RCB + TG3_BDINFO_SIZE * 16;
9250+
else if (tg3_flag(tp, 5717_PLUS))
9251+
limit = NIC_SRAM_SEND_RCB + TG3_BDINFO_SIZE * 4;
9252+
else if (tg3_flag(tp, 57765_CLASS) ||
9253+
tg3_asic_rev(tp) == ASIC_REV_5762)
9254+
limit = NIC_SRAM_SEND_RCB + TG3_BDINFO_SIZE * 2;
9255+
else
9256+
limit = NIC_SRAM_SEND_RCB + TG3_BDINFO_SIZE;
9257+
9258+
for (txrcb = NIC_SRAM_SEND_RCB + TG3_BDINFO_SIZE;
9259+
txrcb < limit; txrcb += TG3_BDINFO_SIZE)
9260+
tg3_write_mem(tp, txrcb + TG3_BDINFO_MAXLEN_FLAGS,
9261+
BDINFO_FLAGS_DISABLED);
9262+
}
9263+
92429264
/* tp->lock is held. */
92439265
static void tg3_tx_rcbs_init(struct tg3 *tp)
92449266
{
@@ -9260,6 +9282,29 @@ static void tg3_tx_rcbs_init(struct tg3 *tp)
92609282
}
92619283
}
92629284

9285+
/* tp->lock is held. */
9286+
static void tg3_rx_ret_rcbs_disable(struct tg3 *tp)
9287+
{
9288+
u32 rxrcb, limit;
9289+
9290+
/* Disable all receive return rings but the first. */
9291+
if (tg3_flag(tp, 5717_PLUS))
9292+
limit = NIC_SRAM_RCV_RET_RCB + TG3_BDINFO_SIZE * 17;
9293+
else if (!tg3_flag(tp, 5705_PLUS))
9294+
limit = NIC_SRAM_RCV_RET_RCB + TG3_BDINFO_SIZE * 16;
9295+
else if (tg3_asic_rev(tp) == ASIC_REV_5755 ||
9296+
tg3_asic_rev(tp) == ASIC_REV_5762 ||
9297+
tg3_flag(tp, 57765_CLASS))
9298+
limit = NIC_SRAM_RCV_RET_RCB + TG3_BDINFO_SIZE * 4;
9299+
else
9300+
limit = NIC_SRAM_RCV_RET_RCB + TG3_BDINFO_SIZE;
9301+
9302+
for (rxrcb = NIC_SRAM_RCV_RET_RCB + TG3_BDINFO_SIZE;
9303+
rxrcb < limit; rxrcb += TG3_BDINFO_SIZE)
9304+
tg3_write_mem(tp, rxrcb + TG3_BDINFO_MAXLEN_FLAGS,
9305+
BDINFO_FLAGS_DISABLED);
9306+
}
9307+
92639308
/* tp->lock is held. */
92649309
static void tg3_rx_ret_rcbs_init(struct tg3 *tp)
92659310
{
@@ -9285,42 +9330,12 @@ static void tg3_rx_ret_rcbs_init(struct tg3 *tp)
92859330
static void tg3_rings_reset(struct tg3 *tp)
92869331
{
92879332
int i;
9288-
u32 stblk, txrcb, rxrcb, limit;
9333+
u32 stblk;
92899334
struct tg3_napi *tnapi = &tp->napi[0];
92909335

9291-
/* Disable all transmit rings but the first. */
9292-
if (!tg3_flag(tp, 5705_PLUS))
9293-
limit = NIC_SRAM_SEND_RCB + TG3_BDINFO_SIZE * 16;
9294-
else if (tg3_flag(tp, 5717_PLUS))
9295-
limit = NIC_SRAM_SEND_RCB + TG3_BDINFO_SIZE * 4;
9296-
else if (tg3_flag(tp, 57765_CLASS) ||
9297-
tg3_asic_rev(tp) == ASIC_REV_5762)
9298-
limit = NIC_SRAM_SEND_RCB + TG3_BDINFO_SIZE * 2;
9299-
else
9300-
limit = NIC_SRAM_SEND_RCB + TG3_BDINFO_SIZE;
9301-
9302-
for (txrcb = NIC_SRAM_SEND_RCB + TG3_BDINFO_SIZE;
9303-
txrcb < limit; txrcb += TG3_BDINFO_SIZE)
9304-
tg3_write_mem(tp, txrcb + TG3_BDINFO_MAXLEN_FLAGS,
9305-
BDINFO_FLAGS_DISABLED);
9306-
9307-
9308-
/* Disable all receive return rings but the first. */
9309-
if (tg3_flag(tp, 5717_PLUS))
9310-
limit = NIC_SRAM_RCV_RET_RCB + TG3_BDINFO_SIZE * 17;
9311-
else if (!tg3_flag(tp, 5705_PLUS))
9312-
limit = NIC_SRAM_RCV_RET_RCB + TG3_BDINFO_SIZE * 16;
9313-
else if (tg3_asic_rev(tp) == ASIC_REV_5755 ||
9314-
tg3_asic_rev(tp) == ASIC_REV_5762 ||
9315-
tg3_flag(tp, 57765_CLASS))
9316-
limit = NIC_SRAM_RCV_RET_RCB + TG3_BDINFO_SIZE * 4;
9317-
else
9318-
limit = NIC_SRAM_RCV_RET_RCB + TG3_BDINFO_SIZE;
9336+
tg3_tx_rcbs_disable(tp);
93199337

9320-
for (rxrcb = NIC_SRAM_RCV_RET_RCB + TG3_BDINFO_SIZE;
9321-
rxrcb < limit; rxrcb += TG3_BDINFO_SIZE)
9322-
tg3_write_mem(tp, rxrcb + TG3_BDINFO_MAXLEN_FLAGS,
9323-
BDINFO_FLAGS_DISABLED);
9338+
tg3_rx_ret_rcbs_disable(tp);
93249339

93259340
/* Disable interrupts */
93269341
tw32_mailbox_f(tp->napi[0].int_mbox, 1);

0 commit comments

Comments
 (0)