18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (c) 2016 Chelsio Communications, Inc.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify
58c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License as published by
68c2ecf20Sopenharmony_ci * the Free Software Foundation.
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#ifndef	__CXGBIT_LRO_H__
118c2ecf20Sopenharmony_ci#define	__CXGBIT_LRO_H__
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <linux/kernel.h>
148c2ecf20Sopenharmony_ci#include <linux/module.h>
158c2ecf20Sopenharmony_ci#include <linux/errno.h>
168c2ecf20Sopenharmony_ci#include <linux/types.h>
178c2ecf20Sopenharmony_ci#include <linux/skbuff.h>
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define LRO_FLUSH_LEN_MAX	65535
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_cistruct cxgbit_lro_cb {
228c2ecf20Sopenharmony_ci	struct cxgbit_sock *csk;
238c2ecf20Sopenharmony_ci	u32 pdu_totallen;
248c2ecf20Sopenharmony_ci	u32 offset;
258c2ecf20Sopenharmony_ci	u8 pdu_idx;
268c2ecf20Sopenharmony_ci	bool complete;
278c2ecf20Sopenharmony_ci};
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_cienum cxgbit_pducb_flags {
308c2ecf20Sopenharmony_ci	PDUCBF_RX_HDR		= (1 << 0), /* received pdu header */
318c2ecf20Sopenharmony_ci	PDUCBF_RX_DATA		= (1 << 1), /* received pdu payload */
328c2ecf20Sopenharmony_ci	PDUCBF_RX_STATUS	= (1 << 2), /* received ddp status */
338c2ecf20Sopenharmony_ci	PDUCBF_RX_DATA_DDPD	= (1 << 3), /* pdu payload ddp'd */
348c2ecf20Sopenharmony_ci	PDUCBF_RX_DDP_CMP	= (1 << 4), /* ddp completion */
358c2ecf20Sopenharmony_ci	PDUCBF_RX_HCRC_ERR	= (1 << 5), /* header digest error */
368c2ecf20Sopenharmony_ci	PDUCBF_RX_DCRC_ERR	= (1 << 6), /* data digest error */
378c2ecf20Sopenharmony_ci};
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_cistruct cxgbit_lro_pdu_cb {
408c2ecf20Sopenharmony_ci	u8 flags;
418c2ecf20Sopenharmony_ci	u8 frags;
428c2ecf20Sopenharmony_ci	u8 hfrag_idx;
438c2ecf20Sopenharmony_ci	u8 nr_dfrags;
448c2ecf20Sopenharmony_ci	u8 dfrag_idx;
458c2ecf20Sopenharmony_ci	bool complete;
468c2ecf20Sopenharmony_ci	u32 seq;
478c2ecf20Sopenharmony_ci	u32 pdulen;
488c2ecf20Sopenharmony_ci	u32 hlen;
498c2ecf20Sopenharmony_ci	u32 dlen;
508c2ecf20Sopenharmony_ci	u32 doffset;
518c2ecf20Sopenharmony_ci	u32 ddigest;
528c2ecf20Sopenharmony_ci	void *hdr;
538c2ecf20Sopenharmony_ci};
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci#define LRO_SKB_MAX_HEADROOM  \
568c2ecf20Sopenharmony_ci		(sizeof(struct cxgbit_lro_cb) + \
578c2ecf20Sopenharmony_ci		 (MAX_SKB_FRAGS * sizeof(struct cxgbit_lro_pdu_cb)))
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#define LRO_SKB_MIN_HEADROOM  \
608c2ecf20Sopenharmony_ci		(sizeof(struct cxgbit_lro_cb) + \
618c2ecf20Sopenharmony_ci		 sizeof(struct cxgbit_lro_pdu_cb))
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci#define cxgbit_skb_lro_cb(skb)	((struct cxgbit_lro_cb *)skb->data)
648c2ecf20Sopenharmony_ci#define cxgbit_skb_lro_pdu_cb(skb, i)	\
658c2ecf20Sopenharmony_ci	((struct cxgbit_lro_pdu_cb *)(skb->data + sizeof(struct cxgbit_lro_cb) \
668c2ecf20Sopenharmony_ci		+ (i * sizeof(struct cxgbit_lro_pdu_cb))))
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci#define CPL_RX_ISCSI_DDP_STATUS_DDP_SHIFT	16 /* ddp'able */
698c2ecf20Sopenharmony_ci#define CPL_RX_ISCSI_DDP_STATUS_PAD_SHIFT	19 /* pad error */
708c2ecf20Sopenharmony_ci#define CPL_RX_ISCSI_DDP_STATUS_HCRC_SHIFT	20 /* hcrc error */
718c2ecf20Sopenharmony_ci#define CPL_RX_ISCSI_DDP_STATUS_DCRC_SHIFT	21 /* dcrc error */
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#endif	/*__CXGBIT_LRO_H_*/
74