Skip to content

Commit 4c826fe

Browse files
chelsiocryptoherbertx
authored andcommitted
crypto: chelsio - request to HW should wrap
-Tx request and data is copied to HW Q in 64B desc, check for end of queue and adjust the current position to start from beginning before passing the additional request info. -key context copy should check key length only -Few reverse christmas tree correction Signed-off-by: Atul Gupta <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 7024e0d commit 4c826fe

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

drivers/crypto/chelsio/chcr_ipsec.c

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -346,18 +346,23 @@ inline void *copy_cpltx_pktxt(struct sk_buff *skb,
346346
struct net_device *dev,
347347
void *pos)
348348
{
349+
struct cpl_tx_pkt_core *cpl;
350+
struct sge_eth_txq *q;
349351
struct adapter *adap;
350352
struct port_info *pi;
351-
struct sge_eth_txq *q;
352-
struct cpl_tx_pkt_core *cpl;
353-
u64 cntrl = 0;
354353
u32 ctrl0, qidx;
354+
u64 cntrl = 0;
355+
int left;
355356

356357
pi = netdev_priv(dev);
357358
adap = pi->adapter;
358359
qidx = skb->queue_mapping;
359360
q = &adap->sge.ethtxq[qidx + pi->first_qset];
360361

362+
left = (void *)q->q.stat - pos;
363+
if (!left)
364+
pos = q->q.desc;
365+
361366
cpl = (struct cpl_tx_pkt_core *)pos;
362367

363368
cntrl = TXPKT_L4CSUM_DIS_F | TXPKT_IPCSUM_DIS_F;
@@ -382,18 +387,17 @@ inline void *copy_key_cpltx_pktxt(struct sk_buff *skb,
382387
void *pos,
383388
struct ipsec_sa_entry *sa_entry)
384389
{
385-
struct adapter *adap;
386-
struct port_info *pi;
387-
struct sge_eth_txq *q;
388-
unsigned int len, qidx;
389390
struct _key_ctx *key_ctx;
390391
int left, eoq, key_len;
392+
struct sge_eth_txq *q;
393+
struct adapter *adap;
394+
struct port_info *pi;
395+
unsigned int qidx;
391396

392397
pi = netdev_priv(dev);
393398
adap = pi->adapter;
394399
qidx = skb->queue_mapping;
395400
q = &adap->sge.ethtxq[qidx + pi->first_qset];
396-
len = sa_entry->enckey_len + sizeof(struct cpl_tx_pkt_core);
397401
key_len = sa_entry->kctx_len;
398402

399403
/* end of queue, reset pos to start of queue */
@@ -411,19 +415,14 @@ inline void *copy_key_cpltx_pktxt(struct sk_buff *skb,
411415
pos += sizeof(struct _key_ctx);
412416
left -= sizeof(struct _key_ctx);
413417

414-
if (likely(len <= left)) {
418+
if (likely(key_len <= left)) {
415419
memcpy(key_ctx->key, sa_entry->key, key_len);
416420
pos += key_len;
417421
} else {
418-
if (key_len <= left) {
419-
memcpy(pos, sa_entry->key, key_len);
420-
pos += key_len;
421-
} else {
422-
memcpy(pos, sa_entry->key, left);
423-
memcpy(q->q.desc, sa_entry->key + left,
424-
key_len - left);
425-
pos = (u8 *)q->q.desc + (key_len - left);
426-
}
422+
memcpy(pos, sa_entry->key, left);
423+
memcpy(q->q.desc, sa_entry->key + left,
424+
key_len - left);
425+
pos = (u8 *)q->q.desc + (key_len - left);
427426
}
428427
/* Copy CPL TX PKT XT */
429428
pos = copy_cpltx_pktxt(skb, dev, pos);

0 commit comments

Comments
 (0)