From a328cdc046f7dd4d50e10d9ceb2388f64763f0a8 Mon Sep 17 00:00:00 2001 From: Steve Wise Date: Thu, 15 Jan 2015 11:08:33 -0600 Subject: [PATCH] cxgbi: Backport for RHEL6.6 Signed-off-by: Steve Wise --- patches/0016-BACKPORT-cxgbi.patch | 232 ++++++++++++++++++++++++++++-- 1 file changed, 220 insertions(+), 12 deletions(-) diff --git a/patches/0016-BACKPORT-cxgbi.patch b/patches/0016-BACKPORT-cxgbi.patch index 9bc3406..10917d4 100644 --- a/patches/0016-BACKPORT-cxgbi.patch +++ b/patches/0016-BACKPORT-cxgbi.patch @@ -5,10 +5,10 @@ Signed-off-by: Steve Wise --- drivers/scsi/cxgbi/cxgb3i/Kbuild | 2 +- drivers/scsi/cxgbi/cxgb4i/Kbuild | 2 +- - drivers/scsi/cxgbi/cxgb4i/cxgb4i.c | 10 ++++++++ - drivers/scsi/cxgbi/libcxgbi.c | 42 ++++++++++++++++++++++++++++++++++++ - drivers/scsi/cxgbi/libcxgbi.h | 4 +++ - 5 files changed, 58 insertions(+), 2 deletions(-) + drivers/scsi/cxgbi/cxgb4i/cxgb4i.c | 10 +++ + drivers/scsi/cxgbi/libcxgbi.c | 133 +++++++++++++++++++++++++++++++++++- + drivers/scsi/cxgbi/libcxgbi.h | 8 ++ + 5 files changed, 152 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/cxgbi/cxgb3i/Kbuild b/drivers/scsi/cxgbi/cxgb3i/Kbuild index xxxxxxx..xxxxxxx xxxxxx @@ -76,10 +76,77 @@ diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c index xxxxxxx..xxxxxxx xxxxxx --- a/drivers/scsi/cxgbi/libcxgbi.c +++ b/drivers/scsi/cxgbi/libcxgbi.c -@@ -613,7 +613,11 @@ static struct cxgbi_sock *cxgbi_check_route(struct sockaddr *dst_addr) +@@ -576,16 +576,41 @@ static struct cxgbi_sock *cxgbi_sock_create(struct cxgbi_device *cdev) + return csk; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0) + static struct rtable *find_route_ipv4(struct flowi4 *fl4, ++#else ++static struct rtable *find_route_ipv4( ++#endif + __be32 saddr, __be32 daddr, + __be16 sport, __be16 dport, u8 tos) + { + struct rtable *rt; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0) + rt = ip_route_output_ports(&init_net, fl4, NULL, daddr, saddr, + dport, sport, IPPROTO_TCP, tos, 0); + if (IS_ERR(rt)) + return NULL; ++#else ++ struct flowi fl = { ++ .oif = 0, ++ .nl_u = { ++ .ip4_u = { ++ .daddr = daddr, ++ .saddr = saddr, ++ .tos = tos} ++ }, ++ .proto = IPPROTO_TCP, ++ .uli_u = { ++ .ports = { ++ .sport = sport, ++ .dport = dport} ++ } ++ }; ++ ++ if (ip_route_output_flow(&init_net, &rt, &fl, NULL, 0)) ++ return NULL; ++#endif + + return rt; + } +@@ -598,13 +623,19 @@ static struct cxgbi_sock *cxgbi_check_route(struct sockaddr *dst_addr) + struct cxgbi_device *cdev; + struct rtable *rt = NULL; + struct neighbour *n; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0) + struct flowi4 fl4; ++#endif + struct cxgbi_sock *csk = NULL; + unsigned int mtu = 0; + int port = 0xFFFF; + int err = 0; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0) + rt = find_route_ipv4(&fl4, 0, daddr->sin_addr.s_addr, 0, daddr->sin_port, 0); ++#else ++ rt = find_route_ipv4(0, daddr->sin_addr.s_addr, 0, daddr->sin_port, 0); ++#endif + if (!rt) { + pr_info("no route to ipv4 0x%x, port %u.\n", + be32_to_cpu(daddr->sin_addr.s_addr), +@@ -612,8 +643,16 @@ static struct cxgbi_sock *cxgbi_check_route(struct sockaddr *dst_addr) + err = -ENETUNREACH; goto err_out; } ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0) dst = &rt->dst; ++#else ++ dst = &rt->u.dst; ++#endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0) n = dst_neigh_lookup(dst, &daddr->sin_addr.s_addr); +#else @@ -88,10 +155,15 @@ index xxxxxxx..xxxxxxx xxxxxx if (!n) { err = -ENODEV; goto rel_rt; -@@ -663,12 +667,16 @@ static struct cxgbi_sock *cxgbi_check_route(struct sockaddr *dst_addr) +@@ -662,13 +701,21 @@ static struct cxgbi_sock *cxgbi_check_route(struct sockaddr *dst_addr) + csk->daddr.sin_port = daddr->sin_port; csk->daddr.sin_family = daddr->sin_family; csk->saddr.sin_family = daddr->sin_family; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0) csk->saddr.sin_addr.s_addr = fl4.saddr; ++#else ++ csk->saddr.sin_addr.s_addr = rt->rt_src; ++#endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0) neigh_release(n); +#endif @@ -105,9 +177,40 @@ index xxxxxxx..xxxxxxx xxxxxx rel_rt: ip_rt_put(rt); -@@ -717,7 +725,11 @@ static struct cxgbi_sock *cxgbi_check_route6(struct sockaddr *dst_addr) +@@ -682,6 +729,7 @@ err_out: + static struct rt6_info *find_route_ipv6(const struct in6_addr *saddr, + const struct in6_addr *daddr) + { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0) + struct flowi6 fl; + + if (saddr) +@@ -689,6 +737,16 @@ static struct rt6_info *find_route_ipv6(const struct in6_addr *saddr, + if (daddr) + memcpy(&fl.daddr, daddr, sizeof(struct in6_addr)); + return (struct rt6_info *)ip6_route_output(&init_net, NULL, &fl); ++#else ++ struct flowi fl; ++ ++ memset(&fl, 0, sizeof(fl)); ++ fl.proto = IPPROTO_TCP; ++ ipv6_addr_copy(&fl.fl6_src, (struct in6_addr *)saddr); ++ ipv6_addr_copy(&fl.fl6_dst, (struct in6_addr *)daddr); ++ ++ return (struct rt6_info *)ip6_route_output(&init_net, NULL, &fl); ++#endif + } + + static struct cxgbi_sock *cxgbi_check_route6(struct sockaddr *dst_addr) +@@ -715,9 +773,17 @@ static struct cxgbi_sock *cxgbi_check_route6(struct sockaddr *dst_addr) + goto err_out; + } ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0) dst = &rt->dst; ++#else ++ dst = &rt->u.dst; ++#endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0) n = dst_neigh_lookup(dst, &daddr6->sin6_addr); @@ -117,7 +220,7 @@ index xxxxxxx..xxxxxxx xxxxxx if (!n) { pr_info("%pI6, port %u, dst no neighbour.\n", -@@ -781,14 +793,22 @@ static struct cxgbi_sock *cxgbi_check_route6(struct sockaddr *dst_addr) +@@ -781,14 +847,22 @@ static struct cxgbi_sock *cxgbi_check_route6(struct sockaddr *dst_addr) csk->saddr6.sin6_family = daddr6->sin6_family; csk->saddr6.sin6_addr = pref_saddr; @@ -135,12 +238,105 @@ index xxxxxxx..xxxxxxx xxxxxx +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) ip6_rt_put(rt); +#else -+ dst_release(&rt->dst); ++ dst_release(dst); +#endif if (csk) cxgbi_sock_closed(csk); err_out: -@@ -2414,7 +2434,25 @@ int cxgbi_set_conn_param(struct iscsi_cls_conn *cls_conn, +@@ -1063,8 +1137,11 @@ unsigned int cxgbi_sock_select_mss(struct cxgbi_sock *csk, unsigned int pmtu) + { + unsigned int idx; + struct dst_entry *dst = csk->dst; +- ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38) + csk->advmss = dst_metric_advmss(dst); ++#else ++ csk->advmss = dst_metric(dst, RTAX_ADVMSS); ++#endif + + if (csk->advmss > pmtu - 40) + csk->advmss = pmtu - 40; +@@ -2036,7 +2113,11 @@ static int sgl_seek_offset(struct scatterlist *sgl, unsigned int sgcnt, + } + + static int sgl_read_to_frags(struct scatterlist *sg, unsigned int sgoffset, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) + unsigned int dlen, struct page_frag *frags, ++#else ++ unsigned int dlen, skb_frag_t *frags, ++#endif + int frag_max) + { + unsigned int datalen = dlen; +@@ -2063,7 +2144,11 @@ static int sgl_read_to_frags(struct scatterlist *sg, unsigned int sgoffset, + copy = min(datalen, sglen); + if (i && page == frags[i - 1].page && + sgoffset + sg->offset == ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) + frags[i - 1].offset + frags[i - 1].size) { ++#else ++ frags[i - 1].page_offset + frags[i - 1].size) { ++#endif + frags[i - 1].size += copy; + } else { + if (i >= frag_max) { +@@ -2073,7 +2158,11 @@ static int sgl_read_to_frags(struct scatterlist *sg, unsigned int sgoffset, + } + + frags[i].page = page; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) + frags[i].offset = sg->offset + sgoffset; ++#else ++ frags[i].page_offset = sg->offset + sgoffset; ++#endif + frags[i].size = copy; + i++; + } +@@ -2194,15 +2283,31 @@ int cxgbi_conn_init_pdu(struct iscsi_task *task, unsigned int offset, + if (tdata->nr_frags > MAX_SKB_FRAGS || + (padlen && tdata->nr_frags == MAX_SKB_FRAGS)) { + char *dst = skb->data + task->hdr_len; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) + struct page_frag *frag = tdata->frags; ++#else ++ skb_frag_t *frag = tdata->frags; ++#endif + + /* data fits in the skb's headroom */ + for (i = 0; i < tdata->nr_frags; i++, frag++) { ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) + char *src = kmap_atomic(frag->page); ++#else ++ char *src = kmap_atomic(frag->page, KM_SOFTIRQ0); ++#endif + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) + memcpy(dst, src+frag->offset, frag->size); ++#else ++ memcpy(dst, src+frag->page_offset, frag->size); ++#endif + dst += frag->size; ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) + kunmap_atomic(src); ++#else ++ kunmap_atomic(src, KM_SOFTIRQ0); ++#endif + } + if (padlen) { + memset(dst, 0, padlen); +@@ -2214,7 +2319,11 @@ int cxgbi_conn_init_pdu(struct iscsi_task *task, unsigned int offset, + for (i = 0; i < tdata->nr_frags; i++) { + __skb_fill_page_desc(skb, i, + tdata->frags[i].page, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) + tdata->frags[i].offset, ++#else ++ tdata->frags[i].page_offset, ++#endif + tdata->frags[i].size); + skb_frag_ref(skb, i); + } +@@ -2414,7 +2523,25 @@ int cxgbi_set_conn_param(struct iscsi_cls_conn *cls_conn, conn->datadgst_en, 0); break; case ISCSI_PARAM_MAX_R2T: @@ -166,7 +362,7 @@ index xxxxxxx..xxxxxxx xxxxxx case ISCSI_PARAM_MAX_RECV_DLENGTH: err = iscsi_set_param(cls_conn, param, buf, buflen); if (!err) -@@ -2850,7 +2888,11 @@ void cxgbi_iscsi_cleanup(struct iscsi_transport *itp, +@@ -2850,7 +2977,11 @@ void cxgbi_iscsi_cleanup(struct iscsi_transport *itp, } EXPORT_SYMBOL_GPL(cxgbi_iscsi_cleanup); @@ -182,7 +378,19 @@ diff --git a/drivers/scsi/cxgbi/libcxgbi.h b/drivers/scsi/cxgbi/libcxgbi.h index xxxxxxx..xxxxxxx xxxxxx --- a/drivers/scsi/cxgbi/libcxgbi.h +++ b/drivers/scsi/cxgbi/libcxgbi.h -@@ -724,7 +724,11 @@ int cxgbi_conn_xmit_pdu(struct iscsi_task *); +@@ -591,7 +591,11 @@ struct cxgbi_endpoint { + #define MAX_PDU_FRAGS ((ULP2_MAX_PDU_PAYLOAD + 512 - 1) / 512) + struct cxgbi_task_data { + unsigned short nr_frags; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) + struct page_frag frags[MAX_PDU_FRAGS]; ++#else ++ skb_frag_t frags[MAX_PDU_FRAGS]; ++#endif + struct sk_buff *skb; + unsigned int offset; + unsigned int count; +@@ -724,7 +728,11 @@ int cxgbi_conn_xmit_pdu(struct iscsi_task *); void cxgbi_cleanup_task(struct iscsi_task *task); -- 2.41.0