Skip to content

Commit 0e0704b

Browse files
committed
Merge branch 'ch_tlss-fixes'
Vinay Kumar Yadav says: ==================== chelsio/ch_ktls: chelsio inline tls driver bug fixes This series of patches fix following bugs in Chelsio inline tls driver. Patch1: kernel panic. Patch2: connection close issue. Patch3: tcb close call issue. Patch4: unnecessary snd_una update. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 61d7735 + e8a4155 commit 0e0704b

1 file changed

Lines changed: 11 additions & 91 deletions

File tree

  • drivers/net/ethernet/chelsio/inline_crypto/ch_ktls

drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c

Lines changed: 11 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -349,18 +349,6 @@ static int chcr_set_tcb_field(struct chcr_ktls_info *tx_info, u16 word,
349349
return cxgb4_ofld_send(tx_info->netdev, skb);
350350
}
351351

352-
/*
353-
* chcr_ktls_mark_tcb_close: mark tcb state to CLOSE
354-
* @tx_info - driver specific tls info.
355-
* return: NET_TX_OK/NET_XMIT_DROP.
356-
*/
357-
static int chcr_ktls_mark_tcb_close(struct chcr_ktls_info *tx_info)
358-
{
359-
return chcr_set_tcb_field(tx_info, TCB_T_STATE_W,
360-
TCB_T_STATE_V(TCB_T_STATE_M),
361-
CHCR_TCB_STATE_CLOSED, 1);
362-
}
363-
364352
/*
365353
* chcr_ktls_dev_del: call back for tls_dev_del.
366354
* Remove the tid and l2t entry and close the connection.
@@ -395,8 +383,6 @@ static void chcr_ktls_dev_del(struct net_device *netdev,
395383

396384
/* clear tid */
397385
if (tx_info->tid != -1) {
398-
/* clear tcb state and then release tid */
399-
chcr_ktls_mark_tcb_close(tx_info);
400386
cxgb4_remove_tid(&tx_info->adap->tids, tx_info->tx_chan,
401387
tx_info->tid, tx_info->ip_family);
402388
}
@@ -574,7 +560,6 @@ static int chcr_ktls_dev_add(struct net_device *netdev, struct sock *sk,
574560
return 0;
575561

576562
free_tid:
577-
chcr_ktls_mark_tcb_close(tx_info);
578563
#if IS_ENABLED(CONFIG_IPV6)
579564
/* clear clip entry */
580565
if (tx_info->ip_family == AF_INET6)
@@ -672,10 +657,6 @@ static int chcr_ktls_cpl_act_open_rpl(struct adapter *adap,
672657
if (tx_info->pending_close) {
673658
spin_unlock(&tx_info->lock);
674659
if (!status) {
675-
/* it's a late success, tcb status is established,
676-
* mark it close.
677-
*/
678-
chcr_ktls_mark_tcb_close(tx_info);
679660
cxgb4_remove_tid(&tx_info->adap->tids, tx_info->tx_chan,
680661
tid, tx_info->ip_family);
681662
}
@@ -1663,54 +1644,6 @@ static void chcr_ktls_copy_record_in_skb(struct sk_buff *nskb,
16631644
refcount_add(nskb->truesize, &nskb->sk->sk_wmem_alloc);
16641645
}
16651646

1666-
/*
1667-
* chcr_ktls_update_snd_una: Reset the SEND_UNA. It will be done to avoid
1668-
* sending the same segment again. It will discard the segment which is before
1669-
* the current tx max.
1670-
* @tx_info - driver specific tls info.
1671-
* @q - TX queue.
1672-
* return: NET_TX_OK/NET_XMIT_DROP.
1673-
*/
1674-
static int chcr_ktls_update_snd_una(struct chcr_ktls_info *tx_info,
1675-
struct sge_eth_txq *q)
1676-
{
1677-
struct fw_ulptx_wr *wr;
1678-
unsigned int ndesc;
1679-
int credits;
1680-
void *pos;
1681-
u32 len;
1682-
1683-
len = sizeof(*wr) + roundup(CHCR_SET_TCB_FIELD_LEN, 16);
1684-
ndesc = DIV_ROUND_UP(len, 64);
1685-
1686-
credits = chcr_txq_avail(&q->q) - ndesc;
1687-
if (unlikely(credits < 0)) {
1688-
chcr_eth_txq_stop(q);
1689-
return NETDEV_TX_BUSY;
1690-
}
1691-
1692-
pos = &q->q.desc[q->q.pidx];
1693-
1694-
wr = pos;
1695-
/* ULPTX wr */
1696-
wr->op_to_compl = htonl(FW_WR_OP_V(FW_ULPTX_WR));
1697-
wr->cookie = 0;
1698-
/* fill len in wr field */
1699-
wr->flowid_len16 = htonl(FW_WR_LEN16_V(DIV_ROUND_UP(len, 16)));
1700-
1701-
pos += sizeof(*wr);
1702-
1703-
pos = chcr_write_cpl_set_tcb_ulp(tx_info, q, tx_info->tid, pos,
1704-
TCB_SND_UNA_RAW_W,
1705-
TCB_SND_UNA_RAW_V(TCB_SND_UNA_RAW_M),
1706-
TCB_SND_UNA_RAW_V(0), 0);
1707-
1708-
chcr_txq_advance(&q->q, ndesc);
1709-
cxgb4_ring_tx_db(tx_info->adap, &q->q, ndesc);
1710-
1711-
return 0;
1712-
}
1713-
17141647
/*
17151648
* chcr_end_part_handler: This handler will handle the record which
17161649
* is complete or if record's end part is received. T6 adapter has a issue that
@@ -1735,7 +1668,9 @@ static int chcr_end_part_handler(struct chcr_ktls_info *tx_info,
17351668
struct sge_eth_txq *q, u32 skb_offset,
17361669
u32 tls_end_offset, bool last_wr)
17371670
{
1671+
bool free_skb_if_tx_fails = false;
17381672
struct sk_buff *nskb = NULL;
1673+
17391674
/* check if it is a complete record */
17401675
if (tls_end_offset == record->len) {
17411676
nskb = skb;
@@ -1758,6 +1693,8 @@ static int chcr_end_part_handler(struct chcr_ktls_info *tx_info,
17581693

17591694
if (last_wr)
17601695
dev_kfree_skb_any(skb);
1696+
else
1697+
free_skb_if_tx_fails = true;
17611698

17621699
last_wr = true;
17631700

@@ -1769,6 +1706,8 @@ static int chcr_end_part_handler(struct chcr_ktls_info *tx_info,
17691706
record->num_frags,
17701707
(last_wr && tcp_push_no_fin),
17711708
mss)) {
1709+
if (free_skb_if_tx_fails)
1710+
dev_kfree_skb_any(skb);
17721711
goto out;
17731712
}
17741713
tx_info->prev_seq = record->end_seq;
@@ -1905,11 +1844,6 @@ static int chcr_short_record_handler(struct chcr_ktls_info *tx_info,
19051844
/* reset tcp_seq as per the prior_data_required len */
19061845
tcp_seq -= prior_data_len;
19071846
}
1908-
/* reset snd una, so the middle record won't send the already
1909-
* sent part.
1910-
*/
1911-
if (chcr_ktls_update_snd_una(tx_info, q))
1912-
goto out;
19131847
atomic64_inc(&tx_info->adap->ch_ktls_stats.ktls_tx_middle_pkts);
19141848
} else {
19151849
atomic64_inc(&tx_info->adap->ch_ktls_stats.ktls_tx_start_pkts);
@@ -2010,12 +1944,11 @@ static int chcr_ktls_xmit(struct sk_buff *skb, struct net_device *dev)
20101944
* we will send the complete record again.
20111945
*/
20121946

1947+
spin_lock_irqsave(&tx_ctx->base.lock, flags);
1948+
20131949
do {
2014-
int i;
20151950

20161951
cxgb4_reclaim_completed_tx(adap, &q->q, true);
2017-
/* lock taken */
2018-
spin_lock_irqsave(&tx_ctx->base.lock, flags);
20191952
/* fetch the tls record */
20201953
record = tls_get_record(&tx_ctx->base, tcp_seq,
20211954
&tx_info->record_no);
@@ -2074,11 +2007,11 @@ static int chcr_ktls_xmit(struct sk_buff *skb, struct net_device *dev)
20742007
tls_end_offset, skb_offset,
20752008
0);
20762009

2077-
spin_unlock_irqrestore(&tx_ctx->base.lock, flags);
20782010
if (ret) {
20792011
/* free the refcount taken earlier */
20802012
if (tls_end_offset < data_len)
20812013
dev_kfree_skb_any(skb);
2014+
spin_unlock_irqrestore(&tx_ctx->base.lock, flags);
20822015
goto out;
20832016
}
20842017

@@ -2088,16 +2021,6 @@ static int chcr_ktls_xmit(struct sk_buff *skb, struct net_device *dev)
20882021
continue;
20892022
}
20902023

2091-
/* increase page reference count of the record, so that there
2092-
* won't be any chance of page free in middle if in case stack
2093-
* receives ACK and try to delete the record.
2094-
*/
2095-
for (i = 0; i < record->num_frags; i++)
2096-
__skb_frag_ref(&record->frags[i]);
2097-
/* lock cleared */
2098-
spin_unlock_irqrestore(&tx_ctx->base.lock, flags);
2099-
2100-
21012024
/* if a tls record is finishing in this SKB */
21022025
if (tls_end_offset <= data_len) {
21032026
ret = chcr_end_part_handler(tx_info, skb, record,
@@ -2122,13 +2045,9 @@ static int chcr_ktls_xmit(struct sk_buff *skb, struct net_device *dev)
21222045
data_len = 0;
21232046
}
21242047

2125-
/* clear the frag ref count which increased locally before */
2126-
for (i = 0; i < record->num_frags; i++) {
2127-
/* clear the frag ref count */
2128-
__skb_frag_unref(&record->frags[i]);
2129-
}
21302048
/* if any failure, come out from the loop. */
21312049
if (ret) {
2050+
spin_unlock_irqrestore(&tx_ctx->base.lock, flags);
21322051
if (th->fin)
21332052
dev_kfree_skb_any(skb);
21342053

@@ -2143,6 +2062,7 @@ static int chcr_ktls_xmit(struct sk_buff *skb, struct net_device *dev)
21432062

21442063
} while (data_len > 0);
21452064

2065+
spin_unlock_irqrestore(&tx_ctx->base.lock, flags);
21462066
atomic64_inc(&port_stats->ktls_tx_encrypted_packets);
21472067
atomic64_add(skb_data_len, &port_stats->ktls_tx_encrypted_bytes);
21482068

0 commit comments

Comments
 (0)