Skip to content

Commit 9806307

Browse files
John Fastabenddavem330
authored andcommitted
ixgbe: DCB, fix TX hang occurring in stress condition with PFC
The DCB credits refill quantum _must_ be greater than half the max packet size. This is needed to guarantee that TX DMA operations are not attempted during a pause state. Additionally, the min IFG must be set correctly for DCB mode. If a DMA operation is requested unexpectedly during the pause state the HW data store may be corrupted leading to a DMA hang. The DMA hang requires a reset to correct. This fixes the HW configuration to avoid this condition. Signed-off-by: John Fastabend <[email protected]> Tested-by: Ross Brattain <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent affa9df commit 9806307

File tree

5 files changed

+54
-10
lines changed

5 files changed

+54
-10
lines changed

drivers/net/ixgbe/ixgbe_dcb.c

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@
4343
* ixgbe_dcb_check_config().
4444
*/
4545
s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_dcb_config *dcb_config,
46-
u8 direction)
46+
int max_frame, u8 direction)
4747
{
4848
struct tc_bw_alloc *p;
49+
int min_credit;
50+
int min_multiplier;
51+
int min_percent = 100;
4952
s32 ret_val = 0;
5053
/* Initialization values default for Tx settings */
5154
u32 credit_refill = 0;
@@ -59,6 +62,31 @@ s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_dcb_config *dcb_config,
5962
goto out;
6063
}
6164

65+
min_credit = ((max_frame / 2) + DCB_CREDIT_QUANTUM - 1) /
66+
DCB_CREDIT_QUANTUM;
67+
68+
/* Find smallest link percentage */
69+
for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
70+
p = &dcb_config->tc_config[i].path[direction];
71+
bw_percent = dcb_config->bw_percentage[direction][p->bwg_id];
72+
link_percentage = p->bwg_percent;
73+
74+
link_percentage = (link_percentage * bw_percent) / 100;
75+
76+
if (link_percentage && link_percentage < min_percent)
77+
min_percent = link_percentage;
78+
}
79+
80+
/*
81+
* The ratio between traffic classes will control the bandwidth
82+
* percentages seen on the wire. To calculate this ratio we use
83+
* a multiplier. It is required that the refill credits must be
84+
* larger than the max frame size so here we find the smallest
85+
* multiplier that will allow all bandwidth percentages to be
86+
* greater than the max frame size.
87+
*/
88+
min_multiplier = (min_credit / min_percent) + 1;
89+
6290
/* Find out the link percentage for each TC first */
6391
for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
6492
p = &dcb_config->tc_config[i].path[direction];
@@ -73,8 +101,9 @@ s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_dcb_config *dcb_config,
73101
/* Save link_percentage for reference */
74102
p->link_percent = (u8)link_percentage;
75103

76-
/* Calculate credit refill and save it */
77-
credit_refill = link_percentage * MINIMUM_CREDIT_REFILL;
104+
/* Calculate credit refill ratio using multiplier */
105+
credit_refill = min(link_percentage * min_multiplier,
106+
MAX_CREDIT_REFILL);
78107
p->data_credits_refill = (u16)credit_refill;
79108

80109
/* Calculate maximum credit for the TC */
@@ -85,8 +114,8 @@ s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_dcb_config *dcb_config,
85114
* of a TC is too small, the maximum credit may not be
86115
* enough to send out a jumbo frame in data plane arbitration.
87116
*/
88-
if (credit_max && (credit_max < MINIMUM_CREDIT_FOR_JUMBO))
89-
credit_max = MINIMUM_CREDIT_FOR_JUMBO;
117+
if (credit_max && (credit_max < min_credit))
118+
credit_max = min_credit;
90119

91120
if (direction == DCB_TX_CONFIG) {
92121
/*

drivers/net/ixgbe/ixgbe_dcb.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,14 @@ struct ixgbe_dcb_config {
150150
/* DCB driver APIs */
151151

152152
/* DCB credits calculation */
153-
s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_dcb_config *, u8);
153+
s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_dcb_config *, int, u8);
154154

155155
/* DCB hw initialization */
156156
s32 ixgbe_dcb_hw_config(struct ixgbe_hw *, struct ixgbe_dcb_config *);
157157

158158
/* DCB definitions for credit calculation */
159+
#define DCB_CREDIT_QUANTUM 64 /* DCB Quantum */
159160
#define MAX_CREDIT_REFILL 511 /* 0x1FF * 64B = 32704B */
160-
#define MINIMUM_CREDIT_REFILL 5 /* 5*64B = 320B */
161-
#define MINIMUM_CREDIT_FOR_JUMBO 145 /* 145= UpperBound((9*1024+54)/64B) for 9KB jumbo frame */
162161
#define DCB_MAX_TSO_SIZE (32*1024) /* MAX TSO packet size supported in DCB mode */
163162
#define MINIMUM_CREDIT_FOR_TSO (DCB_MAX_TSO_SIZE/64 + 1) /* 513 for 32KB TSO packet */
164163
#define MAX_CREDIT 4095 /* Maximum credit supported: 256KB * 1204 / 64B */

drivers/net/ixgbe/ixgbe_dcb_82599.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,11 @@ static s32 ixgbe_dcb_config_82599(struct ixgbe_hw *hw)
397397
reg &= ~IXGBE_RTTDCS_ARBDIS;
398398
IXGBE_WRITE_REG(hw, IXGBE_RTTDCS, reg);
399399

400+
/* Enable Security TX Buffer IFG for DCB */
401+
reg = IXGBE_READ_REG(hw, IXGBE_SECTXMINIFG);
402+
reg |= IXGBE_SECTX_DCB;
403+
IXGBE_WRITE_REG(hw, IXGBE_SECTXMINIFG, reg);
404+
400405
return 0;
401406
}
402407

drivers/net/ixgbe/ixgbe_dcb_82599.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@
9595

9696
#define IXGBE_TXPBTHRESH_DCB 0xA /* THRESH value for DCB mode */
9797

98+
/* SECTXMINIFG DCB */
99+
#define IXGBE_SECTX_DCB 0x00001F00 /* DCB TX Buffer IFG */
100+
98101

99102
/* DCB hardware-specific driver APIs */
100103

drivers/net/ixgbe/ixgbe_main.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3347,6 +3347,7 @@ static void ixgbe_napi_disable_all(struct ixgbe_adapter *adapter)
33473347
static void ixgbe_configure_dcb(struct ixgbe_adapter *adapter)
33483348
{
33493349
struct ixgbe_hw *hw = &adapter->hw;
3350+
int max_frame = adapter->netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
33503351
u32 txdctl;
33513352
int i, j;
33523353

@@ -3359,8 +3360,15 @@ static void ixgbe_configure_dcb(struct ixgbe_adapter *adapter)
33593360
if (hw->mac.type == ixgbe_mac_82598EB)
33603361
netif_set_gso_max_size(adapter->netdev, 32768);
33613362

3362-
ixgbe_dcb_calculate_tc_credits(&adapter->dcb_cfg, DCB_TX_CONFIG);
3363-
ixgbe_dcb_calculate_tc_credits(&adapter->dcb_cfg, DCB_RX_CONFIG);
3363+
#ifdef CONFIG_FCOE
3364+
if (adapter->netdev->features & NETIF_F_FCOE_MTU)
3365+
max_frame = max(max_frame, IXGBE_FCOE_JUMBO_FRAME_SIZE);
3366+
#endif
3367+
3368+
ixgbe_dcb_calculate_tc_credits(&adapter->dcb_cfg, max_frame,
3369+
DCB_TX_CONFIG);
3370+
ixgbe_dcb_calculate_tc_credits(&adapter->dcb_cfg, max_frame,
3371+
DCB_RX_CONFIG);
33643372

33653373
/* reconfigure the hardware */
33663374
ixgbe_dcb_hw_config(&adapter->hw, &adapter->dcb_cfg);

0 commit comments

Comments
 (0)