Skip to content

Commit 59437d7

Browse files
Shahjada Abul Husaindavem330
authored andcommitted
cxgb4/chtls: fix ULD connection failures due to wrong TID base
Currently, the hardware TID index is assumed to start from index 0. However, with the following changeset, commit c219399 ("cxgb4: add support for high priority filters") hardware TID index can start after the high priority region, which has introduced a regression resulting in connection failures for ULDs. So, fix all related code to properly recalculate the TID start index based on whether high priority filters are enabled or not. Fixes: c219399 ("cxgb4: add support for high priority filters") Signed-off-by: Shahjada Abul Husain <shahjada@chelsio.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3646ae0 commit 59437d7

File tree

5 files changed

+32
-26
lines changed

5 files changed

+32
-26
lines changed

drivers/crypto/chelsio/chtls/chtls_cm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,7 @@ static int chtls_pass_accept_req(struct chtls_dev *cdev, struct sk_buff *skb)
12731273
ctx = (struct listen_ctx *)data;
12741274
lsk = ctx->lsk;
12751275

1276-
if (unlikely(tid >= cdev->tids->ntids)) {
1276+
if (unlikely(tid_out_of_range(cdev->tids, tid))) {
12771277
pr_info("passive open TID %u too large\n", tid);
12781278
return 1;
12791279
}

drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3171,14 +3171,12 @@ static const struct file_operations mem_debugfs_fops = {
31713171

31723172
static int tid_info_show(struct seq_file *seq, void *v)
31733173
{
3174-
unsigned int tid_start = 0;
31753174
struct adapter *adap = seq->private;
3176-
const struct tid_info *t = &adap->tids;
3177-
enum chip_type chip = CHELSIO_CHIP_VERSION(adap->params.chip);
3178-
3179-
if (chip > CHELSIO_T5)
3180-
tid_start = t4_read_reg(adap, LE_DB_ACTIVE_TABLE_START_INDEX_A);
3175+
const struct tid_info *t;
3176+
enum chip_type chip;
31813177

3178+
t = &adap->tids;
3179+
chip = CHELSIO_CHIP_VERSION(adap->params.chip);
31823180
if (t4_read_reg(adap, LE_DB_CONFIG_A) & HASHEN_F) {
31833181
unsigned int sb;
31843182
seq_printf(seq, "Connections in use: %u\n",
@@ -3190,9 +3188,9 @@ static int tid_info_show(struct seq_file *seq, void *v)
31903188
sb = t4_read_reg(adap, LE_DB_SRVR_START_INDEX_A);
31913189

31923190
if (sb) {
3193-
seq_printf(seq, "TID range: %u..%u/%u..%u", tid_start,
3191+
seq_printf(seq, "TID range: %u..%u/%u..%u", t->tid_base,
31943192
sb - 1, adap->tids.hash_base,
3195-
t->ntids - 1);
3193+
t->tid_base + t->ntids - 1);
31963194
seq_printf(seq, ", in use: %u/%u\n",
31973195
atomic_read(&t->tids_in_use),
31983196
atomic_read(&t->hash_tids_in_use));
@@ -3201,23 +3199,23 @@ static int tid_info_show(struct seq_file *seq, void *v)
32013199
t->aftid_base,
32023200
t->aftid_end,
32033201
adap->tids.hash_base,
3204-
t->ntids - 1);
3202+
t->tid_base + t->ntids - 1);
32053203
seq_printf(seq, ", in use: %u/%u\n",
32063204
atomic_read(&t->tids_in_use),
32073205
atomic_read(&t->hash_tids_in_use));
32083206
} else {
32093207
seq_printf(seq, "TID range: %u..%u",
32103208
adap->tids.hash_base,
3211-
t->ntids - 1);
3209+
t->tid_base + t->ntids - 1);
32123210
seq_printf(seq, ", in use: %u\n",
32133211
atomic_read(&t->hash_tids_in_use));
32143212
}
32153213
} else if (t->ntids) {
32163214
seq_printf(seq, "Connections in use: %u\n",
32173215
atomic_read(&t->conns_in_use));
32183216

3219-
seq_printf(seq, "TID range: %u..%u", tid_start,
3220-
tid_start + t->ntids - 1);
3217+
seq_printf(seq, "TID range: %u..%u", t->tid_base,
3218+
t->tid_base + t->ntids - 1);
32213219
seq_printf(seq, ", in use: %u\n",
32223220
atomic_read(&t->tids_in_use));
32233221
}

drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,11 @@ static int get_filter_count(struct adapter *adapter, unsigned int fidx,
361361

362362
tcb_base = t4_read_reg(adapter, TP_CMM_TCB_BASE_A);
363363
if (is_hashfilter(adapter) && hash) {
364-
if (fidx < adapter->tids.ntids) {
365-
f = adapter->tids.tid_tab[fidx];
366-
if (!f)
367-
return -EINVAL;
368-
} else {
364+
if (tid_out_of_range(&adapter->tids, fidx))
369365
return -E2BIG;
370-
}
366+
f = adapter->tids.tid_tab[fidx - adapter->tids.tid_base];
367+
if (!f)
368+
return -EINVAL;
371369
} else {
372370
if ((fidx != (adapter->tids.nftids + adapter->tids.nsftids +
373371
adapter->tids.nhpftids - 1)) &&
@@ -1615,7 +1613,7 @@ static int cxgb4_del_hash_filter(struct net_device *dev, int filter_id,
16151613
netdev_dbg(dev, "%s: filter_id = %d ; nftids = %d\n",
16161614
__func__, filter_id, adapter->tids.nftids);
16171615

1618-
if (filter_id > adapter->tids.ntids)
1616+
if (tid_out_of_range(t, filter_id))
16191617
return -E2BIG;
16201618

16211619
f = lookup_tid(t, filter_id);

drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,8 +1447,8 @@ static void mk_tid_release(struct sk_buff *skb, unsigned int chan,
14471447
static void cxgb4_queue_tid_release(struct tid_info *t, unsigned int chan,
14481448
unsigned int tid)
14491449
{
1450-
void **p = &t->tid_tab[tid];
14511450
struct adapter *adap = container_of(t, struct adapter, tids);
1451+
void **p = &t->tid_tab[tid - t->tid_base];
14521452

14531453
spin_lock_bh(&adap->tid_release_lock);
14541454
*p = adap->tid_release_head;
@@ -1500,13 +1500,13 @@ static void process_tid_release_list(struct work_struct *work)
15001500
void cxgb4_remove_tid(struct tid_info *t, unsigned int chan, unsigned int tid,
15011501
unsigned short family)
15021502
{
1503-
struct sk_buff *skb;
15041503
struct adapter *adap = container_of(t, struct adapter, tids);
1504+
struct sk_buff *skb;
15051505

1506-
WARN_ON(tid >= t->ntids);
1506+
WARN_ON(tid_out_of_range(&adap->tids, tid));
15071507

1508-
if (t->tid_tab[tid]) {
1509-
t->tid_tab[tid] = NULL;
1508+
if (t->tid_tab[tid - adap->tids.tid_base]) {
1509+
t->tid_tab[tid - adap->tids.tid_base] = NULL;
15101510
atomic_dec(&t->conns_in_use);
15111511
if (t->hash_base && (tid >= t->hash_base)) {
15121512
if (family == AF_INET6)
@@ -4727,6 +4727,9 @@ static int adap_init0(struct adapter *adap, int vpd_skip)
47274727
adap->rawf_start = val[0];
47284728
adap->rawf_cnt = val[1] - val[0] + 1;
47294729
}
4730+
4731+
adap->tids.tid_base =
4732+
t4_read_reg(adap, LE_DB_ACTIVE_TABLE_START_INDEX_A);
47304733
}
47314734

47324735
/* qids (ingress/egress) returned from firmware can be anywhere

drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ struct eotid_entry {
9999
*/
100100
struct tid_info {
101101
void **tid_tab;
102+
unsigned int tid_base;
102103
unsigned int ntids;
103104

104105
struct serv_entry *stid_tab;
@@ -152,9 +153,15 @@ struct tid_info {
152153

153154
static inline void *lookup_tid(const struct tid_info *t, unsigned int tid)
154155
{
156+
tid -= t->tid_base;
155157
return tid < t->ntids ? t->tid_tab[tid] : NULL;
156158
}
157159

160+
static inline bool tid_out_of_range(const struct tid_info *t, unsigned int tid)
161+
{
162+
return ((tid - t->tid_base) >= t->ntids);
163+
}
164+
158165
static inline void *lookup_atid(const struct tid_info *t, unsigned int atid)
159166
{
160167
return atid < t->natids ? t->atid_tab[atid].data : NULL;
@@ -176,7 +183,7 @@ static inline void *lookup_stid(const struct tid_info *t, unsigned int stid)
176183
static inline void cxgb4_insert_tid(struct tid_info *t, void *data,
177184
unsigned int tid, unsigned short family)
178185
{
179-
t->tid_tab[tid] = data;
186+
t->tid_tab[tid - t->tid_base] = data;
180187
if (t->hash_base && (tid >= t->hash_base)) {
181188
if (family == AF_INET6)
182189
atomic_add(2, &t->hash_tids_in_use);

0 commit comments

Comments
 (0)