aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaren Xie <kxie@chelsio.com>2008-12-19 01:56:20 -0500
committerDavid S. Miller <davem@davemloft.net>2008-12-19 01:56:20 -0500
commita109a5b916bc180e14fad0d1e9c37a08c85652c0 (patch)
tree03bf2fffff72aeb2dc881091bb728c83251598c8
parent221b3d60cbb2740ec7d46a4f1ea6d3318a112e51 (diff)
cxgb3: manage private iSCSI IP address
The accelerated iSCSI traffic could use a private IP address unknown to the OS: - The IP address is required in both drivers to manage ARP requests and connection set up. - Added an control call to retrieve the ip address. - Reply to ARP requests dedicated to the private IP address. Signed-off-by: Divy Le Ray <divy@chelsio.com> Signed-off-by: Karen Xie <kxie@chelsio.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/cxgb3/adapter.h1
-rw-r--r--drivers/net/cxgb3/cxgb3_ctl_defs.h7
-rw-r--r--drivers/net/cxgb3/cxgb3_offload.c67
-rw-r--r--drivers/net/cxgb3/sge.c67
4 files changed, 121 insertions, 21 deletions
diff --git a/drivers/net/cxgb3/adapter.h b/drivers/net/cxgb3/adapter.h
index c190a69c4d71..5b346f9eaa8b 100644
--- a/drivers/net/cxgb3/adapter.h
+++ b/drivers/net/cxgb3/adapter.h
@@ -63,6 +63,7 @@ struct port_info {
63 struct link_config link_config; 63 struct link_config link_config;
64 struct net_device_stats netstats; 64 struct net_device_stats netstats;
65 int activity; 65 int activity;
66 __be32 iscsi_ipv4addr;
66}; 67};
67 68
68enum { /* adapter flags */ 69enum { /* adapter flags */
diff --git a/drivers/net/cxgb3/cxgb3_ctl_defs.h b/drivers/net/cxgb3/cxgb3_ctl_defs.h
index 1d8d46eb3c96..55099eb3c70e 100644
--- a/drivers/net/cxgb3/cxgb3_ctl_defs.h
+++ b/drivers/net/cxgb3/cxgb3_ctl_defs.h
@@ -57,6 +57,7 @@ enum {
57 RDMA_GET_MIB = 19, 57 RDMA_GET_MIB = 19,
58 58
59 GET_RX_PAGE_INFO = 50, 59 GET_RX_PAGE_INFO = 50,
60 GET_ISCSI_IPV4ADDR = 51,
60}; 61};
61 62
62/* 63/*
@@ -86,6 +87,12 @@ struct iff_mac {
86 u16 vlan_tag; 87 u16 vlan_tag;
87}; 88};
88 89
90/* Structure used to request a port's iSCSI IPv4 address */
91struct iscsi_ipv4addr {
92 struct net_device *dev; /* the net_device */
93 __be32 ipv4addr; /* the return iSCSI IPv4 address */
94};
95
89struct pci_dev; 96struct pci_dev;
90 97
91/* 98/*
diff --git a/drivers/net/cxgb3/cxgb3_offload.c b/drivers/net/cxgb3/cxgb3_offload.c
index 265aa8a15afa..1ce69b742804 100644
--- a/drivers/net/cxgb3/cxgb3_offload.c
+++ b/drivers/net/cxgb3/cxgb3_offload.c
@@ -182,7 +182,9 @@ static struct net_device *get_iff_from_mac(struct adapter *adapter,
182static int cxgb_ulp_iscsi_ctl(struct adapter *adapter, unsigned int req, 182static int cxgb_ulp_iscsi_ctl(struct adapter *adapter, unsigned int req,
183 void *data) 183 void *data)
184{ 184{
185 int i;
185 int ret = 0; 186 int ret = 0;
187 unsigned int val = 0;
186 struct ulp_iscsi_info *uiip = data; 188 struct ulp_iscsi_info *uiip = data;
187 189
188 switch (req) { 190 switch (req) {
@@ -191,32 +193,55 @@ static int cxgb_ulp_iscsi_ctl(struct adapter *adapter, unsigned int req,
191 uiip->llimit = t3_read_reg(adapter, A_ULPRX_ISCSI_LLIMIT); 193 uiip->llimit = t3_read_reg(adapter, A_ULPRX_ISCSI_LLIMIT);
192 uiip->ulimit = t3_read_reg(adapter, A_ULPRX_ISCSI_ULIMIT); 194 uiip->ulimit = t3_read_reg(adapter, A_ULPRX_ISCSI_ULIMIT);
193 uiip->tagmask = t3_read_reg(adapter, A_ULPRX_ISCSI_TAGMASK); 195 uiip->tagmask = t3_read_reg(adapter, A_ULPRX_ISCSI_TAGMASK);
196
197 val = t3_read_reg(adapter, A_ULPRX_ISCSI_PSZ);
198 for (i = 0; i < 4; i++, val >>= 8)
199 uiip->pgsz_factor[i] = val & 0xFF;
200
201 val = t3_read_reg(adapter, A_TP_PARA_REG7);
202 uiip->max_txsz =
203 uiip->max_rxsz = min((val >> S_PMMAXXFERLEN0)&M_PMMAXXFERLEN0,
204 (val >> S_PMMAXXFERLEN1)&M_PMMAXXFERLEN1);
194 /* 205 /*
195 * On tx, the iscsi pdu has to be <= tx page size and has to 206 * On tx, the iscsi pdu has to be <= tx page size and has to
196 * fit into the Tx PM FIFO. 207 * fit into the Tx PM FIFO.
197 */ 208 */
198 uiip->max_txsz = min(adapter->params.tp.tx_pg_size, 209 val = min(adapter->params.tp.tx_pg_size,
199 t3_read_reg(adapter, A_PM1_TX_CFG) >> 17); 210 t3_read_reg(adapter, A_PM1_TX_CFG) >> 17);
200 /* on rx, the iscsi pdu has to be < rx page size and the 211 uiip->max_txsz = min(val, uiip->max_txsz);
201 whole pdu + cpl headers has to fit into one sge buffer */ 212
202 uiip->max_rxsz = min_t(unsigned int, 213 /* set MaxRxData to 16224 */
203 adapter->params.tp.rx_pg_size, 214 val = t3_read_reg(adapter, A_TP_PARA_REG2);
204 (adapter->sge.qs[0].fl[1].buf_size - 215 if ((val >> S_MAXRXDATA) != 0x3f60) {
205 sizeof(struct cpl_rx_data) * 2 - 216 val &= (M_RXCOALESCESIZE << S_RXCOALESCESIZE);
206 sizeof(struct cpl_rx_data_ddp))); 217 val |= V_MAXRXDATA(0x3f60);
218 printk(KERN_INFO
219 "%s, iscsi set MaxRxData to 16224 (0x%x).\n",
220 adapter->name, val);
221 t3_write_reg(adapter, A_TP_PARA_REG2, val);
222 }
223
224 /*
225 * on rx, the iscsi pdu has to be < rx page size and the
226 * the max rx data length programmed in TP
227 */
228 val = min(adapter->params.tp.rx_pg_size,
229 ((t3_read_reg(adapter, A_TP_PARA_REG2)) >>
230 S_MAXRXDATA) & M_MAXRXDATA);
231 uiip->max_rxsz = min(val, uiip->max_rxsz);
207 break; 232 break;
208 case ULP_ISCSI_SET_PARAMS: 233 case ULP_ISCSI_SET_PARAMS:
209 t3_write_reg(adapter, A_ULPRX_ISCSI_TAGMASK, uiip->tagmask); 234 t3_write_reg(adapter, A_ULPRX_ISCSI_TAGMASK, uiip->tagmask);
210 /* set MaxRxData and MaxCoalesceSize to 16224 */
211 t3_write_reg(adapter, A_TP_PARA_REG2, 0x3f603f60);
212 /* program the ddp page sizes */ 235 /* program the ddp page sizes */
213 { 236 for (i = 0; i < 4; i++)
214 int i; 237 val |= (uiip->pgsz_factor[i] & 0xF) << (8 * i);
215 unsigned int val = 0; 238 if (val && (val != t3_read_reg(adapter, A_ULPRX_ISCSI_PSZ))) {
216 for (i = 0; i < 4; i++) 239 printk(KERN_INFO
217 val |= (uiip->pgsz_factor[i] & 0xF) << (8 * i); 240 "%s, setting iscsi pgsz 0x%x, %u,%u,%u,%u.\n",
218 if (val) 241 adapter->name, val, uiip->pgsz_factor[0],
219 t3_write_reg(adapter, A_ULPRX_ISCSI_PSZ, val); 242 uiip->pgsz_factor[1], uiip->pgsz_factor[2],
243 uiip->pgsz_factor[3]);
244 t3_write_reg(adapter, A_ULPRX_ISCSI_PSZ, val);
220 } 245 }
221 break; 246 break;
222 default: 247 default:
@@ -407,6 +432,12 @@ static int cxgb_offload_ctl(struct t3cdev *tdev, unsigned int req, void *data)
407 rx_page_info->page_size = tp->rx_pg_size; 432 rx_page_info->page_size = tp->rx_pg_size;
408 rx_page_info->num = tp->rx_num_pgs; 433 rx_page_info->num = tp->rx_num_pgs;
409 break; 434 break;
435 case GET_ISCSI_IPV4ADDR: {
436 struct iscsi_ipv4addr *p = data;
437 struct port_info *pi = netdev_priv(p->dev);
438 p->ipv4addr = pi->iscsi_ipv4addr;
439 break;
440 }
410 default: 441 default:
411 return -EOPNOTSUPP; 442 return -EOPNOTSUPP;
412 } 443 }
diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c
index 63eb97473c8b..6c641a889471 100644
--- a/drivers/net/cxgb3/sge.c
+++ b/drivers/net/cxgb3/sge.c
@@ -36,6 +36,7 @@
36#include <linux/ip.h> 36#include <linux/ip.h>
37#include <linux/tcp.h> 37#include <linux/tcp.h>
38#include <linux/dma-mapping.h> 38#include <linux/dma-mapping.h>
39#include <net/arp.h>
39#include "common.h" 40#include "common.h"
40#include "regs.h" 41#include "regs.h"
41#include "sge_defs.h" 42#include "sge_defs.h"
@@ -1863,6 +1864,54 @@ static void restart_tx(struct sge_qset *qs)
1863} 1864}
1864 1865
1865/** 1866/**
1867 * cxgb3_arp_process - process an ARP request probing a private IP address
1868 * @adapter: the adapter
1869 * @skb: the skbuff containing the ARP request
1870 *
1871 * Check if the ARP request is probing the private IP address
1872 * dedicated to iSCSI, generate an ARP reply if so.
1873 */
1874static void cxgb3_arp_process(struct adapter *adapter, struct sk_buff *skb)
1875{
1876 struct net_device *dev = skb->dev;
1877 struct port_info *pi;
1878 struct arphdr *arp;
1879 unsigned char *arp_ptr;
1880 unsigned char *sha;
1881 __be32 sip, tip;
1882
1883 if (!dev)
1884 return;
1885
1886 skb_reset_network_header(skb);
1887 arp = arp_hdr(skb);
1888
1889 if (arp->ar_op != htons(ARPOP_REQUEST))
1890 return;
1891
1892 arp_ptr = (unsigned char *)(arp + 1);
1893 sha = arp_ptr;
1894 arp_ptr += dev->addr_len;
1895 memcpy(&sip, arp_ptr, sizeof(sip));
1896 arp_ptr += sizeof(sip);
1897 arp_ptr += dev->addr_len;
1898 memcpy(&tip, arp_ptr, sizeof(tip));
1899
1900 pi = netdev_priv(dev);
1901 if (tip != pi->iscsi_ipv4addr)
1902 return;
1903
1904 arp_send(ARPOP_REPLY, ETH_P_ARP, sip, dev, tip, sha,
1905 dev->dev_addr, sha);
1906
1907}
1908
1909static inline int is_arp(struct sk_buff *skb)
1910{
1911 return skb->protocol == htons(ETH_P_ARP);
1912}
1913
1914/**
1866 * rx_eth - process an ingress ethernet packet 1915 * rx_eth - process an ingress ethernet packet
1867 * @adap: the adapter 1916 * @adap: the adapter
1868 * @rq: the response queue that received the packet 1917 * @rq: the response queue that received the packet
@@ -1885,7 +1934,7 @@ static void rx_eth(struct adapter *adap, struct sge_rspq *rq,
1885 pi = netdev_priv(skb->dev); 1934 pi = netdev_priv(skb->dev);
1886 if (pi->rx_csum_offload && p->csum_valid && p->csum == htons(0xffff) && 1935 if (pi->rx_csum_offload && p->csum_valid && p->csum == htons(0xffff) &&
1887 !p->fragment) { 1936 !p->fragment) {
1888 rspq_to_qset(rq)->port_stats[SGE_PSTAT_RX_CSUM_GOOD]++; 1937 qs->port_stats[SGE_PSTAT_RX_CSUM_GOOD]++;
1889 skb->ip_summed = CHECKSUM_UNNECESSARY; 1938 skb->ip_summed = CHECKSUM_UNNECESSARY;
1890 } else 1939 } else
1891 skb->ip_summed = CHECKSUM_NONE; 1940 skb->ip_summed = CHECKSUM_NONE;
@@ -1900,16 +1949,28 @@ static void rx_eth(struct adapter *adap, struct sge_rspq *rq,
1900 grp, 1949 grp,
1901 ntohs(p->vlan), 1950 ntohs(p->vlan),
1902 p); 1951 p);
1903 else 1952 else {
1953 if (unlikely(pi->iscsi_ipv4addr &&
1954 is_arp(skb))) {
1955 unsigned short vtag = ntohs(p->vlan) &
1956 VLAN_VID_MASK;
1957 skb->dev = vlan_group_get_device(grp,
1958 vtag);
1959 cxgb3_arp_process(adap, skb);
1960 }
1904 __vlan_hwaccel_rx(skb, grp, ntohs(p->vlan), 1961 __vlan_hwaccel_rx(skb, grp, ntohs(p->vlan),
1905 rq->polling); 1962 rq->polling);
1963 }
1906 else 1964 else
1907 dev_kfree_skb_any(skb); 1965 dev_kfree_skb_any(skb);
1908 } else if (rq->polling) { 1966 } else if (rq->polling) {
1909 if (lro) 1967 if (lro)
1910 lro_receive_skb(&qs->lro_mgr, skb, p); 1968 lro_receive_skb(&qs->lro_mgr, skb, p);
1911 else 1969 else {
1970 if (unlikely(pi->iscsi_ipv4addr && is_arp(skb)))
1971 cxgb3_arp_process(adap, skb);
1912 netif_receive_skb(skb); 1972 netif_receive_skb(skb);
1973 }
1913 } else 1974 } else
1914 netif_rx(skb); 1975 netif_rx(skb);
1915} 1976}