Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ef5d6355 authored by Vipul Pandya's avatar Vipul Pandya Committed by Roland Dreier
Browse files

RDMA/cxgb4: Address sparse warnings



Fixe the following types of sparse warnings
- cast to pointer from integer of different size
- cast from pointer to integer of different size
- incorrect type in assignment (different base types)
- incorrect type in argument 1 (different base types)
- cast from restricted __be64
- cast from restricted __be32

Signed-off-by: default avatarVipul Pandya <vipul@chelsio.com>
Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
parent b3de6cfe
Loading
Loading
Loading
Loading
+38 −30
Original line number Original line Diff line number Diff line
@@ -1492,11 +1492,11 @@ static void send_fw_act_open_req(struct c4iw_ep *ep, unsigned int atid)
			V_FW_OFLD_CONNECTION_WR_ASTID(atid));
			V_FW_OFLD_CONNECTION_WR_ASTID(atid));
	req->tcb.cplrxdataack_cplpassacceptrpl =
	req->tcb.cplrxdataack_cplpassacceptrpl =
			htons(F_FW_OFLD_CONNECTION_WR_CPLRXDATAACK);
			htons(F_FW_OFLD_CONNECTION_WR_CPLRXDATAACK);
	req->tcb.tx_max = jiffies;
	req->tcb.tx_max = (__force __be32) jiffies;
	req->tcb.rcv_adv = htons(1);
	req->tcb.rcv_adv = htons(1);
	cxgb4_best_mtu(ep->com.dev->rdev.lldi.mtus, ep->mtu, &mtu_idx);
	cxgb4_best_mtu(ep->com.dev->rdev.lldi.mtus, ep->mtu, &mtu_idx);
	wscale = compute_wscale(rcv_win);
	wscale = compute_wscale(rcv_win);
	req->tcb.opt0 = TCAM_BYPASS(1) |
	req->tcb.opt0 = (__force __be64) (TCAM_BYPASS(1) |
		(nocong ? NO_CONG(1) : 0) |
		(nocong ? NO_CONG(1) : 0) |
		KEEP_ALIVE(1) |
		KEEP_ALIVE(1) |
		DELACK(1) |
		DELACK(1) |
@@ -1507,20 +1507,20 @@ static void send_fw_act_open_req(struct c4iw_ep *ep, unsigned int atid)
		SMAC_SEL(ep->smac_idx) |
		SMAC_SEL(ep->smac_idx) |
		DSCP(ep->tos) |
		DSCP(ep->tos) |
		ULP_MODE(ULP_MODE_TCPDDP) |
		ULP_MODE(ULP_MODE_TCPDDP) |
		RCV_BUFSIZ(rcv_win >> 10);
		RCV_BUFSIZ(rcv_win >> 10));
	req->tcb.opt2 = PACE(1) |
	req->tcb.opt2 = (__force __be32) (PACE(1) |
		TX_QUEUE(ep->com.dev->rdev.lldi.tx_modq[ep->tx_chan]) |
		TX_QUEUE(ep->com.dev->rdev.lldi.tx_modq[ep->tx_chan]) |
		RX_CHANNEL(0) |
		RX_CHANNEL(0) |
		CCTRL_ECN(enable_ecn) |
		CCTRL_ECN(enable_ecn) |
		RSS_QUEUE_VALID | RSS_QUEUE(ep->rss_qid);
		RSS_QUEUE_VALID | RSS_QUEUE(ep->rss_qid));
	if (enable_tcp_timestamps)
	if (enable_tcp_timestamps)
		req->tcb.opt2 |= TSTAMPS_EN(1);
		req->tcb.opt2 |= (__force __be32) TSTAMPS_EN(1);
	if (enable_tcp_sack)
	if (enable_tcp_sack)
		req->tcb.opt2 |= SACK_EN(1);
		req->tcb.opt2 |= (__force __be32) SACK_EN(1);
	if (wscale && enable_tcp_window_scaling)
	if (wscale && enable_tcp_window_scaling)
		req->tcb.opt2 |= WND_SCALE_EN(1);
		req->tcb.opt2 |= (__force __be32) WND_SCALE_EN(1);
	req->tcb.opt0 = cpu_to_be64(req->tcb.opt0);
	req->tcb.opt0 = cpu_to_be64((__force u64) req->tcb.opt0);
	req->tcb.opt2 = cpu_to_be32(req->tcb.opt2);
	req->tcb.opt2 = cpu_to_be32((__force u32) req->tcb.opt2);
	set_wr_txq(skb, CPL_PRIORITY_CONTROL, ep->ctrlq_idx);
	set_wr_txq(skb, CPL_PRIORITY_CONTROL, ep->ctrlq_idx);
	set_bit(ACT_OFLD_CONN, &ep->com.history);
	set_bit(ACT_OFLD_CONN, &ep->com.history);
	c4iw_l2t_send(&ep->com.dev->rdev, skb, ep->l2t);
	c4iw_l2t_send(&ep->com.dev->rdev, skb, ep->l2t);
@@ -2773,7 +2773,8 @@ static void active_ofld_conn_reply(struct c4iw_dev *dev, struct sk_buff *skb,
	struct c4iw_ep *ep;
	struct c4iw_ep *ep;
	int atid = be32_to_cpu(req->tid);
	int atid = be32_to_cpu(req->tid);


	ep = (struct c4iw_ep *)lookup_atid(dev->rdev.lldi.tids, req->tid);
	ep = (struct c4iw_ep *)lookup_atid(dev->rdev.lldi.tids,
					   (__force u32) req->tid);
	if (!ep)
	if (!ep)
		return;
		return;


@@ -2817,7 +2818,7 @@ static void passive_ofld_conn_reply(struct c4iw_dev *dev, struct sk_buff *skb,
	struct cpl_pass_accept_req *cpl;
	struct cpl_pass_accept_req *cpl;
	int ret;
	int ret;


	rpl_skb = (struct sk_buff *)cpu_to_be64(req->cookie);
	rpl_skb = (__force struct sk_buff *)cpu_to_be64(req->cookie);
	BUG_ON(!rpl_skb);
	BUG_ON(!rpl_skb);
	if (req->retval) {
	if (req->retval) {
		PDBG("%s passive open failure %d\n", __func__, req->retval);
		PDBG("%s passive open failure %d\n", __func__, req->retval);
@@ -2828,7 +2829,8 @@ static void passive_ofld_conn_reply(struct c4iw_dev *dev, struct sk_buff *skb,
	} else {
	} else {
		cpl = (struct cpl_pass_accept_req *)cplhdr(rpl_skb);
		cpl = (struct cpl_pass_accept_req *)cplhdr(rpl_skb);
		OPCODE_TID(cpl) = htonl(MK_OPCODE_TID(CPL_PASS_ACCEPT_REQ,
		OPCODE_TID(cpl) = htonl(MK_OPCODE_TID(CPL_PASS_ACCEPT_REQ,
						      htonl(req->tid)));
					(__force u32) htonl(
					(__force u32) req->tid)));
		ret = pass_accept_req(dev, rpl_skb);
		ret = pass_accept_req(dev, rpl_skb);
		if (!ret)
		if (!ret)
			kfree_skb(rpl_skb);
			kfree_skb(rpl_skb);
@@ -2874,10 +2876,10 @@ static void build_cpl_pass_accept_req(struct sk_buff *skb, int stid , u8 tos)
	struct tcp_options_received tmp_opt;
	struct tcp_options_received tmp_opt;


	/* Store values from cpl_rx_pkt in temporary location. */
	/* Store values from cpl_rx_pkt in temporary location. */
	vlantag = cpl->vlan;
	vlantag = (__force u16) cpl->vlan;
	len = cpl->len;
	len = (__force u16) cpl->len;
	l2info  = cpl->l2info;
	l2info  = (__force u32) cpl->l2info;
	hdr_len = cpl->hdr_len;
	hdr_len = (__force u16) cpl->hdr_len;
	intf = cpl->iff;
	intf = cpl->iff;


	__skb_pull(skb, sizeof(*req) + sizeof(struct rss_header));
	__skb_pull(skb, sizeof(*req) + sizeof(struct rss_header));
@@ -2888,19 +2890,24 @@ static void build_cpl_pass_accept_req(struct sk_buff *skb, int stid , u8 tos)
	 */
	 */
	memset(&tmp_opt, 0, sizeof(tmp_opt));
	memset(&tmp_opt, 0, sizeof(tmp_opt));
	tcp_clear_options(&tmp_opt);
	tcp_clear_options(&tmp_opt);
	tcp_parse_options(skb, &tmp_opt, 0, 0, NULL);
	tcp_parse_options(skb, &tmp_opt, NULL, 0, NULL);


	req = (struct cpl_pass_accept_req *)__skb_push(skb, sizeof(*req));
	req = (struct cpl_pass_accept_req *)__skb_push(skb, sizeof(*req));
	memset(req, 0, sizeof(*req));
	memset(req, 0, sizeof(*req));
	req->l2info = cpu_to_be16(V_SYN_INTF(intf) |
	req->l2info = cpu_to_be16(V_SYN_INTF(intf) |
			 V_SYN_MAC_IDX(G_RX_MACIDX(htonl(l2info))) |
			 V_SYN_MAC_IDX(G_RX_MACIDX(
			 (__force int) htonl(l2info))) |
			 F_SYN_XACT_MATCH);
			 F_SYN_XACT_MATCH);
	req->hdr_len = cpu_to_be32(V_SYN_RX_CHAN(G_RX_CHAN(htonl(l2info))) |
	req->hdr_len = cpu_to_be32(V_SYN_RX_CHAN(G_RX_CHAN(
				V_TCP_HDR_LEN(G_RX_TCPHDR_LEN(htons(hdr_len))) |
					(__force int) htonl(l2info))) |
				V_IP_HDR_LEN(G_RX_IPHDR_LEN(htons(hdr_len))) |
				   V_TCP_HDR_LEN(G_RX_TCPHDR_LEN(
				V_ETH_HDR_LEN(G_RX_ETHHDR_LEN(htonl(l2info))));
					(__force int) htons(hdr_len))) |
	req->vlan = vlantag;
				   V_IP_HDR_LEN(G_RX_IPHDR_LEN(
	req->len = len;
					(__force int) htons(hdr_len))) |
				   V_ETH_HDR_LEN(G_RX_ETHHDR_LEN(
					(__force int) htonl(l2info))));
	req->vlan = (__force __be16) vlantag;
	req->len = (__force __be16) len;
	req->tos_stid = cpu_to_be32(PASS_OPEN_TID(stid) |
	req->tos_stid = cpu_to_be32(PASS_OPEN_TID(stid) |
				    PASS_OPEN_TOS(tos));
				    PASS_OPEN_TOS(tos));
	req->tcpopt.mss = htons(tmp_opt.mss_clamp);
	req->tcpopt.mss = htons(tmp_opt.mss_clamp);
@@ -2929,7 +2936,7 @@ static void send_fw_pass_open_req(struct c4iw_dev *dev, struct sk_buff *skb,
	req->op_compl = htonl(V_WR_OP(FW_OFLD_CONNECTION_WR) | FW_WR_COMPL(1));
	req->op_compl = htonl(V_WR_OP(FW_OFLD_CONNECTION_WR) | FW_WR_COMPL(1));
	req->len16_pkd = htonl(FW_WR_LEN16(DIV_ROUND_UP(sizeof(*req), 16)));
	req->len16_pkd = htonl(FW_WR_LEN16(DIV_ROUND_UP(sizeof(*req), 16)));
	req->le.version_cpl = htonl(F_FW_OFLD_CONNECTION_WR_CPL);
	req->le.version_cpl = htonl(F_FW_OFLD_CONNECTION_WR_CPL);
	req->le.filter = filter;
	req->le.filter = (__force __be32) filter;
	req->le.lport = lport;
	req->le.lport = lport;
	req->le.pport = rport;
	req->le.pport = rport;
	req->le.u.ipv4.lip = laddr;
	req->le.u.ipv4.lip = laddr;
@@ -2955,7 +2962,7 @@ static void send_fw_pass_open_req(struct c4iw_dev *dev, struct sk_buff *skb,
	 * TP will ignore any value > 0 for MSS index.
	 * TP will ignore any value > 0 for MSS index.
	 */
	 */
	req->tcb.opt0 = cpu_to_be64(V_MSS_IDX(0xF));
	req->tcb.opt0 = cpu_to_be64(V_MSS_IDX(0xF));
	req->cookie = cpu_to_be64((u64)skb);
	req->cookie = (__force __u64) cpu_to_be64((u64)skb);


	set_wr_txq(req_skb, CPL_PRIORITY_CONTROL, port_id);
	set_wr_txq(req_skb, CPL_PRIORITY_CONTROL, port_id);
	cxgb4_ofld_send(dev->rdev.lldi.ports[0], req_skb);
	cxgb4_ofld_send(dev->rdev.lldi.ports[0], req_skb);
@@ -3005,7 +3012,8 @@ static int rx_pkt(struct c4iw_dev *dev, struct sk_buff *skb)
	/*
	/*
	 * Calculate the server tid from filter hit index from cpl_rx_pkt.
	 * Calculate the server tid from filter hit index from cpl_rx_pkt.
	 */
	 */
	stid = cpu_to_be32(rss->hash_val) - dev->rdev.lldi.tids->sftid_base
	stid = (__force int) cpu_to_be32((__force u32) rss->hash_val)
					  - dev->rdev.lldi.tids->sftid_base
					  + dev->rdev.lldi.tids->nstids;
					  + dev->rdev.lldi.tids->nstids;


	lep = (struct c4iw_ep *)lookup_stid(dev->rdev.lldi.tids, stid);
	lep = (struct c4iw_ep *)lookup_stid(dev->rdev.lldi.tids, stid);
@@ -3066,10 +3074,10 @@ static int rx_pkt(struct c4iw_dev *dev, struct sk_buff *skb)


	step = dev->rdev.lldi.nrxq / dev->rdev.lldi.nchan;
	step = dev->rdev.lldi.nrxq / dev->rdev.lldi.nchan;
	rss_qid = dev->rdev.lldi.rxq_ids[pi->port_id * step];
	rss_qid = dev->rdev.lldi.rxq_ids[pi->port_id * step];
	window = htons(tcph->window);
	window = (__force u16) htons((__force u16)tcph->window);


	/* Calcuate filter portion for LE region. */
	/* Calcuate filter portion for LE region. */
	filter = cpu_to_be32(select_ntuple(dev, dst, e));
	filter = (__force unsigned int) cpu_to_be32(select_ntuple(dev, dst, e));


	/*
	/*
	 * Synthesize the cpl_pass_accept_req. We have everything except the
	 * Synthesize the cpl_pass_accept_req. We have everything except the
+2 −1
Original line number Original line Diff line number Diff line
@@ -797,7 +797,8 @@ static int c4iw_uld_rx_handler(void *handle, const __be64 *rsp,
		       "RSS %#llx, FL %#llx, len %u\n",
		       "RSS %#llx, FL %#llx, len %u\n",
		       pci_name(ctx->lldi.pdev), gl->va,
		       pci_name(ctx->lldi.pdev), gl->va,
		       (unsigned long long)be64_to_cpu(*rsp),
		       (unsigned long long)be64_to_cpu(*rsp),
		       (unsigned long long)be64_to_cpu(*(u64 *)gl->va),
		       (unsigned long long)be64_to_cpu(
		       *(__force __be64 *)gl->va),
		       gl->tot_len);
		       gl->tot_len);


		return 0;
		return 0;