[ofw] [PATCH 2/3] MTHCA (checksum): adding support for mthca

Tzachi Dar tzachid at mellanox.co.il
Mon Sep 8 00:41:33 PDT 2008


Applied to trunk and branch 

Thanks
Tzachi
> -----Original Message-----
> From: Alex Naslednikov 
> Sent: Thursday, September 04, 2008 7:36 PM
> To: Alex Naslednikov; Tzachi Dar; ofw at lists.openfabrics.org
> Cc: Ishai Rabinovitz
> Subject: [ofw] [PATCH 2/3] MTHCA (checksum): adding support for mthca
> 
>  
> Signed-off by: xalex (Alexander Naslednikov)
> Index: D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/kernel/ib_verbs.h
> ===================================================================
> --- 
> D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/kernel/ib_verbs.h	
> (revision 3105)
> +++ 
> D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/kernel/ib_verbs.h	
> (revision 3106)
> @@ -73,6 +73,7 @@
>  	IB_DEVICE_RC_RNR_NAK_GEN	= (1<<12),
>  	IB_DEVICE_SRQ_RESIZE		= (1<<13),
>  	IB_DEVICE_N_NOTIFY_CQ		= (1<<14),
> +	IB_DEVICE_IPOIB_CSUM		= (1<<18)
>  };
>  
>  struct ib_device_attr {
> Index: D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/kernel/mthca_cmd.c
> ===================================================================
> --- 
> D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/kernel/mthca_cmd.c	
> (revision 3105)
> +++ 
> D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/kernel/mthca_cmd.c	
> (revision 3106)
> @@ -1277,6 +1277,10 @@
>  	/* Check port for UD address vector: */
>  	*(inbox + INIT_HCA_FLAGS_OFFSET / 4) |= cl_hton32(1);
>  
> +	/* Enable IPoIB checksumming if we can: */
> +	if (dev->device_cap_flags & IB_DEVICE_IPOIB_CSUM)
> +		*(inbox + INIT_HCA_FLAGS_OFFSET / 4) |= 
> cl_hton32(7 << 3);
> +
>  	/* We leave wqe_quota, responder_exu, etc as 0 (default) */
>  
>  	/* QPC/EEC/CQC/EQC/RDB attributes */
> Index: D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/kernel/mthca_cmd.h
> ===================================================================
> --- 
> D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/kernel/mthca_cmd.h	
> (revision 3105)
> +++ 
> D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/kernel/mthca_cmd.h	
> (revision 3106)
> @@ -102,6 +102,7 @@
>  	DEV_LIM_FLAG_RAW_IPV6           = 1 << 4,
>  	DEV_LIM_FLAG_RAW_ETHER          = 1 << 5,
>  	DEV_LIM_FLAG_SRQ                = 1 << 6,
> +	DEV_LIM_FLAG_IPOIB_CSUM         = 1 << 7,
>  	DEV_LIM_FLAG_BAD_PKEY_CNTR      = 1 << 8,
>  	DEV_LIM_FLAG_BAD_QKEY_CNTR      = 1 << 9,
>  	DEV_LIM_FLAG_MW                 = 1 << 16,
> Index: D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/kernel/hca_data.c
> ===================================================================
> --- 
> D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/kernel/hca_data.c	
> (revision 3105)
> +++ 
> D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/kernel/hca_data.c	
> (revision 3106)
> @@ -292,7 +292,8 @@
>  	ca_attr_p->modify_srq_depth      = 
> hca_info_p->device_cap_flags & IB_DEVICE_SRQ_RESIZE;
>  	ca_attr_p->system_image_guid_support = 
> hca_info_p->device_cap_flags & IB_DEVICE_SYS_IMAGE_GUID;
>  	ca_attr_p->hw_agents            = FALSE; // in the 
> context of IBAL then agent is implemented on the host
> -
> +	ca_attr_p->ipoib_csum           = 
> hca_info_p->device_cap_flags & IB_DEVICE_IPOIB_CSUM;
> +	
>  	ca_attr_p->num_page_sizes = 1;
>  	ca_attr_p->p_page_size[0] = PAGE_SIZE; // TBD: extract 
> an array of page sizes from HCA cap
>  
> Index: D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/kernel/mthca_main.c
> ===================================================================
> --- 
> D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/kernel/mthca_main.c	
> (revision 3105)
> +++ 
> D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/kernel/mthca_main.c	
> (revision 3106)
> @@ -256,6 +256,11 @@
>  
>  	if (dev_lim->flags & DEV_LIM_FLAG_SRQ)
>  		mdev->mthca_flags |= MTHCA_FLAG_SRQ;
> +	
> +	if (mthca_is_memfree(mdev)) {
> +		if (dev_lim->flags & DEV_LIM_FLAG_IPOIB_CSUM)
> +			mdev->device_cap_flags |= 
> IB_DEVICE_IPOIB_CSUM; //IB_DEVICE_UD_IP_CSUM;
> +	}
>  
>  	return 0;
>  }
> Index: D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/kernel/mthca_cq.c
> ===================================================================
> --- 
> D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/kernel/mthca_cq.c	
> (revision 3105)
> +++ 
> D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/kernel/mthca_cq.c	
> (revision 3106)
> @@ -117,11 +117,21 @@
>  	SYNDROME_INVAL_EEC_STATE_ERR 	 = 0x24
>  };
>  
> +enum {	
> +	MTHCA_NdisPacketTcpChecksumFailed 		= 1 << 1,
> +	MTHCA_NdisPacketUdpChecksumFailed 		= 1 << 2,
> +	MTHCA_NdisPacketIpChecksumFailed 		= 1 << 3,
> +	MTHCA_NdisPacketTcpChecksumSucceeded 	= 1 << 4,
> +	MTHCA_NdisPacketUdpChecksumSucceeded 	= 1 << 5,
> +	MTHCA_NdisPacketIpChecksumSucceeded 	= 1 << 6
> +};
> +
>  struct mthca_cqe {
>  	__be32 my_qpn;
>  	__be32 my_ee;
>  	__be32 rqpn;
> -	__be16 sl_g_mlpath;
> +	u8		sl_ipok;
> +	u8		g_mlpath;
>  	__be16 rlid;
>  	__be32 imm_etype_pkey_eec;
>  	__be32 byte_cnt;
> @@ -435,6 +445,25 @@
>  	*free_cqe = 0;
>  }
>  
> +static inline uint8_t mthca_ib_ipoib_csum_ok(u16 checksum, 
> u8 ip_ok) {
> +	
> +	#define CSUM_VALID_NUM 0xffff
> +	uint8_t res = 0;
> +	
> +	// Verify that IP_OK bit is set and the packet is pure 
> IPv4 packet
> +	if (ip_ok)
> +	{
> +		// IP checksum calculated by MLX4 matched the 
> checksum in the receive packet's 
> +		res |= MTHCA_NdisPacketIpChecksumSucceeded;
> +		if (checksum == CSUM_VALID_NUM) {
> +				// TCP or UDP checksum 
> calculated by MTHCA matched the checksum in the receive packet's 
> +				res |= 
> (MTHCA_NdisPacketUdpChecksumSucceeded |
> +						
> MTHCA_NdisPacketTcpChecksumSucceeded );
> +		}
> +	}
> +	return res;
> +}
> +
>  static inline int mthca_poll_one(struct mthca_dev *dev,
>  				 struct mthca_cq *cq,
>  				 struct mthca_qp **cur_qp,
> @@ -448,6 +477,7 @@
>  	int is_send;
>  	int free_cqe = 1;
>  	int err = 0;
> +	u16 checksum;
>  
>  	HCA_ENTER(HCA_DBG_CQ);
>  	cqe = next_cqe_sw(cq);
> @@ -575,10 +605,12 @@
>  		entry->recv.ud.remote_lid 	   = cqe->rlid;
>  		entry->recv.ud.remote_qp 	   = cqe->rqpn 
> & 0xffffff00;
>  		entry->recv.ud.pkey_index  = 
> (u16)(cl_ntoh32(cqe->imm_etype_pkey_eec) >> 16);
> -		entry->recv.ud.remote_sl   	   = 
> (uint8_t)(cl_ntoh16(cqe->sl_g_mlpath) >> 12);
> -		entry->recv.ud.path_bits = 
> (uint8_t)(cl_ntoh16(cqe->sl_g_mlpath) & 0x7f);
> -		entry->recv.ud.recv_opt   |= 
> cl_ntoh16(cqe->sl_g_mlpath) & 0x80 ?
> -					IB_RECV_OPT_GRH_VALID : 0;
> +		entry->recv.ud.remote_sl	= cqe->sl_ipok >> 4;
> +		entry->recv.ud.path_bits = 
> (uint8_t)(cqe->g_mlpath & 0x7f);
> +		entry->recv.ud.recv_opt   |= cqe->g_mlpath & 
> 0x80 ? IB_RECV_OPT_GRH_VALID : 0;
> +		checksum = (u16)(cl_ntoh32(cqe->rqpn) >> 24) |
> +				((cl_ntoh32(cqe->my_ee) >> 16) 
> & 0xff00);
> +		entry->recv.ud.csum_ok = 
> mthca_ib_ipoib_csum_ok(checksum, 
> +cqe->sl_ipok & 1);
>  	}
>  	if (!is_send && cqe->rlid == 0){
>  		
> HCA_PRINT(TRACE_LEVEL_INFORMATION,HCA_DBG_CQ,("found rlid == 0 \n "));
> Index: D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/kernel/mthca_qp.c
> ===================================================================
> --- 
> D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/kernel/mthca_qp.c	
> (revision 3105)
> +++ 
> D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/kernel/mthca_qp.c	
> (revision 3106)
> @@ -1975,7 +1975,11 @@
>  			 cl_hton32(MTHCA_NEXT_CQ_UPDATE) : 0) |
>  			((wr->send_opt & IB_SEND_OPT_SOLICITED) ?
>  			 cl_hton32(MTHCA_NEXT_SOLICIT) : 0)   |
> -			cl_hton32(1);
> +			((wr->send_opt & IB_SEND_OPT_TX_IP_CSUM) ?
> +			 cl_hton32(MTHCA_NEXT_IP_CSUM) : 0) |
> +			((wr->send_opt & IB_SEND_OPT_TX_TCP_UDP_CSUM) ?
> +			 cl_hton32(MTHCA_NEXT_TCP_UDP_CSUM) : 0) |
> +			 cl_hton32(1);
>  		if (opcode == MTHCA_OPCODE_SEND_IMM||
>  			opcode == MTHCA_OPCODE_RDMA_WRITE_IMM)
>  			((struct mthca_next_seg *) wqe)->imm = 
> wr->immediate_data;
> Index: D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/mthca_wqe.h
> ===================================================================
> --- D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/mthca_wqe.h	
> (revision 3105)
> +++ D:/Windows/MLNX_WINOF_CSUM_ARBEL/hw/mthca/mthca_wqe.h	
> (revision 3106)
> @@ -44,14 +44,16 @@
>  };
>  
>  enum {
> -	MTHCA_NEXT_DBD       = 1 << 7,
> -	MTHCA_NEXT_FENCE     = 1 << 6,
> -	MTHCA_NEXT_CQ_UPDATE = 1 << 3,
> -	MTHCA_NEXT_EVENT_GEN = 1 << 2,
> -	MTHCA_NEXT_SOLICIT   = 1 << 1,
> +	MTHCA_NEXT_DBD			= 1 << 7,
> +	MTHCA_NEXT_FENCE		= 1 << 6,
> +	MTHCA_NEXT_CQ_UPDATE	= 1 << 3,
> +	MTHCA_NEXT_EVENT_GEN	= 1 << 2,
> +	MTHCA_NEXT_SOLICIT		= 1 << 1,
> +	MTHCA_NEXT_IP_CSUM		= 1 << 4,
> +	MTHCA_NEXT_TCP_UDP_CSUM = 1 << 5,
>  
> -	MTHCA_MLX_VL15       = 1 << 17,
> -	MTHCA_MLX_SLR        = 1 << 16
> +	MTHCA_MLX_VL15			= 1 << 17,
> +	MTHCA_MLX_SLR			= 1 << 16
>  };
>  
>  enum {
>  



More information about the ofw mailing list