Skip to content

Commit 5debb18

Browse files
committed
Merge branch 'cxgb4-chtls-fix-issues-related-to-high-priority-region'
Shahjada Abul Husain says: ==================== cxgb4/chtls: fix issues related to high priority region The high priority region introduced by: commit c219399 ("cxgb4: add support for high priority filters") had caused regression in some code paths, leading to connection failures for the ULDs. This series of patches attempt to fix the regressions. Patch 1 fixes some code paths that have been missed to consider the high priority region. Patch 2 fixes ULD connection failures due to wrong TID base that had been shifted after the high priority region. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 8ae6749 + 59437d7 commit 5debb18

File tree

7 files changed

+50
-34
lines changed

7 files changed

+50
-34
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: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -361,20 +361,22 @@ 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 {
372-
if ((fidx != (adapter->tids.nftids +
373-
adapter->tids.nsftids - 1)) &&
374-
fidx >= adapter->tids.nftids)
370+
if ((fidx != (adapter->tids.nftids + adapter->tids.nsftids +
371+
adapter->tids.nhpftids - 1)) &&
372+
fidx >= (adapter->tids.nftids + adapter->tids.nhpftids))
375373
return -E2BIG;
376374

377-
f = &adapter->tids.ftid_tab[fidx];
375+
if (fidx < adapter->tids.nhpftids)
376+
f = &adapter->tids.hpftid_tab[fidx];
377+
else
378+
f = &adapter->tids.ftid_tab[fidx -
379+
adapter->tids.nhpftids];
378380
if (!f->valid)
379381
return -EINVAL;
380382
}
@@ -480,6 +482,7 @@ int cxgb4_get_free_ftid(struct net_device *dev, int family)
480482
ftid -= n;
481483
}
482484
spin_unlock_bh(&t->ftid_lock);
485+
ftid += t->nhpftids;
483486

484487
return found ? ftid : -ENOMEM;
485488
}
@@ -815,10 +818,14 @@ int delete_filter(struct adapter *adapter, unsigned int fidx)
815818
struct filter_entry *f;
816819
int ret;
817820

818-
if (fidx >= adapter->tids.nftids + adapter->tids.nsftids)
821+
if (fidx >= adapter->tids.nftids + adapter->tids.nsftids +
822+
adapter->tids.nhpftids)
819823
return -EINVAL;
820824

821-
f = &adapter->tids.ftid_tab[fidx];
825+
if (fidx < adapter->tids.nhpftids)
826+
f = &adapter->tids.hpftid_tab[fidx];
827+
else
828+
f = &adapter->tids.ftid_tab[fidx - adapter->tids.nhpftids];
822829
ret = writable_filter(f);
823830
if (ret)
824831
return ret;
@@ -1606,7 +1613,7 @@ static int cxgb4_del_hash_filter(struct net_device *dev, int filter_id,
16061613
netdev_dbg(dev, "%s: filter_id = %d ; nftids = %d\n",
16071614
__func__, filter_id, adapter->tids.nftids);
16081615

1609-
if (filter_id > adapter->tids.ntids)
1616+
if (tid_out_of_range(t, filter_id))
16101617
return -E2BIG;
16111618

16121619
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_tc_flower.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,8 @@ int cxgb4_tc_flower_replace(struct net_device *dev,
672672
* 0 to driver. However, the hardware TCAM index
673673
* starts from 0. Hence, the -1 here.
674674
*/
675-
if (cls->common.prio <= adap->tids.nftids) {
675+
if (cls->common.prio <= (adap->tids.nftids +
676+
adap->tids.nhpftids)) {
676677
fidx = cls->common.prio - 1;
677678
if (fidx < adap->tids.nhpftids)
678679
fs->prio = 1;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static int cxgb4_matchall_alloc_filter(struct net_device *dev,
137137
* -1 here. 1 slot is enough to create a wildcard matchall
138138
* VIID rule.
139139
*/
140-
if (cls->common.prio <= adap->tids.nftids)
140+
if (cls->common.prio <= (adap->tids.nftids + adap->tids.nhpftids))
141141
fidx = cls->common.prio - 1;
142142
else
143143
fidx = cxgb4_get_free_ftid(dev, PF_INET);

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)