Add LE hash collision bug fix for active and passive offloaded connections
Subsystems (5)
v3 cover Add LE hash collision bug fix for active and passive offloaded connections
This patch series fixes the LE hash collision issue in cxgb4 and RDMA/cxgb4 drivers in kernel.org.
If the hash functionality is enabled in T4 then tuple information of active and passive offloaded connections are stored in DDR3 memory. LE (Lookup Engine) implements the interface to search this tuple entries using hash algorithm. To avoid LE hash collision, firmware provides new mechanisms to setup active and passive open connections.
In case of active open connection, firmware detects LE hash collision situation and notifies driver. Driver uses fw_ofld_connection work request to offload that connection. Its tuple information will be stored in TCAM memory array.
In case of passive open connection, server filter region is created in TCAM. This region stores the filter which will redirect the incoming SYN packet to offload queues. After this driver tries to establish the connection using firmware work request.
This patch series also adds framework for managing filters and to use T4's filter capabilities.
Following testing has been carried out successfully on this patch series.
1. 1000 active open connections created and saw that tcam_full counter is getting incremented through debugfs file.
2. Multiple passive open connections were created and ran the same test repetatively to verify server filter is getting created and deleted properly.
The patch-series is based on Roland's infiniband tree (for-next branch), and involves changes on cxgb4 and RDMA/cxgb4 drivers. Both linux-rdma and netdev are included in this post for review.
We have some more bug fixes in RDMA/cxgb4 after this patch series. So, we would like to request this series to get mereged through Roland's infiniband for-next tree.
V2: Changed commenting style from kernel-doc format('/**') to normal
V3: Resending the whole patch series again with the missing patches in V2
Thanks,
Vipul Pandya
Vipul Pandya (5):
cxgb4: Add T4 filter support
cxgb4: Add LE hash collision bug fix path in LLD driver RDMA/cxgb4: Fix LE hash collision bug for active open connection RDMA/cxgb4: Fix LE hash collision bug for passive open connection RDMA/cxgb4: Fix bug for active and passive LE hash collision path
drivers/infiniband/hw/cxgb4/cm.c | 789 +++++++++++++++++++--- drivers/infiniband/hw/cxgb4/device.c | 210 ++++++- drivers/infiniband/hw/cxgb4/iw_cxgb4.h | 33 + drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 146 +++++ drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 473 +++++++++++++- drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h | 23 +- drivers/net/ethernet/chelsio/cxgb4/l2t.c | 34 + drivers/net/ethernet/chelsio/cxgb4/l2t.h | 3 + drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 23 +- drivers/net/ethernet/chelsio/cxgb4/t4_msg.h | 66 ++ drivers/net/ethernet/chelsio/cxgb4/t4_regs.h | 37 ++ drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h | 388 +++++++++++ 12 files changed, 2100 insertions(+), 125 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 1/5 cxgb4: Add T4 filter support
In reply to a message not in the archiveThe T4 architecture is capable of filtering ingress packets at line rate using the rule in TCAM. If packet hits a rule in the TCAM then it can be either dropped or passed to the receive queues based on a rule settings.
This patch adds framework for managing filters and to use T4's filter capabilities. It constructs a Firmware Filter Work Request which writes the filter at a specified index to get the work done. It hosts shadow copy of ingress filter entry to check field size limitations and save memory in the case where the filter table is large.
---
V2: Changed commenting style from kernel-doc format('/**') to normal
V3: Resending the whole patch series again with the missing patches in V2
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 134 ++++++++++ drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 301 ++++++++++++++++++++++- drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h | 2 + drivers/net/ethernet/chelsio/cxgb4/l2t.c | 33 +++ drivers/net/ethernet/chelsio/cxgb4/l2t.h | 3 + drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 23 ++- drivers/net/ethernet/chelsio/cxgb4/t4_msg.h | 1 + drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h | 279 +++++++++++++++++++++ 8 files changed, 770 insertions(+), 6 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +134 -0
@@ -545,6 +545,132 @@ struct adapter {spinlock_t stats_lock; }; +/* +* Defined bit width of user definable filter tuples +*/ +#define ETHTYPE_BITWIDTH 16 +#define FRAG_BITWIDTH 1 +#define MACIDX_BITWIDTH 9 +#define FCOE_BITWIDTH 1 +#define IPORT_BITWIDTH 3 +#define MATCHTYPE_BITWIDTH 3 +#define PROTO_BITWIDTH 8 +#define TOS_BITWIDTH 8 +#define PF_BITWIDTH 8 +#define VF_BITWIDTH 8 +#define IVLAN_BITWIDTH 16 +#define OVLAN_BITWIDTH 16 + +/* Filter matching rules. These consist of a set of ingress packet field +* (value, mask) tuples. The associated ingress packet field matches the +* tuple when ((field & mask) == value). (Thus a wildcard "don't care" field +* rule can be constructed by specifying a tuple of (0, 0).) A filter rule +* matches an ingress packet when all of the individual individual field +* matching rules are true. +* +* Partial field masks are always valid, however, while it may be easy to +* understand their meanings for some fields (e.g. IP address to match a +* subnet), for others making sensible partial masks is less intuitive (e.g. +* MPS match type) ... +* +* Most of the following data structures are modeled on T4 capabilities. +* Drivers for earlier chips use the subsets which make sense for those chips. +* We really need to come up with a hardware-independent mechanism to +* represent hardware filter capabilities ... +*/ +struct ch_filter_tuple { +/* +* Compressed header matching field rules. The TP_VLAN_PRI_MAP +* register selects which of these fields will participate in the +* filter match rules -- up to a maximum of 36 bits. Because +* TP_VLAN_PRI_MAP is a global register, all filters must use the same +* set of fields. +*/ +uint32_t ethtype:ETHTYPE_BITWIDTH ;/* Ethernet type */ +uint32_t frag:FRAG_BITWIDTH ;/* IP fragmentation header */ +uint32_t ivlan_vld:1 ;/* inner VLAN valid */ +uint32_t ovlan_vld:1 ;/* outer VLAN valid */ +uint32_t pfvf_vld:1 ;/* PF/VF valid */ +uint32_t macidx:MACIDX_BITWIDTH ;/* exact match MAC index */ +uint32_t fcoe:FCOE_BITWIDTH ;/* FCoE packet */ +uint32_t iport:IPORT_BITWIDTH ;/* ingress port */ +uint32_t matchtype:MATCHTYPE_BITWIDTH ;/* MPS match type */ +uint32_t proto:PROTO_BITWIDTH ;/* protocol type */ +uint32_t tos:TOS_BITWIDTH ;/* TOS/Traffic Type */ +uint32_t pf:PF_BITWIDTH ;/* PCI-E PF ID */ +uint32_t vf:VF_BITWIDTH ;/* PCI-E VF ID */ +uint32_t ivlan:IVLAN_BITWIDTH ;/* inner VLAN */ +uint32_t ovlan:OVLAN_BITWIDTH ;/* outer VLAN */ + +/* Uncompressed header matching field rules. These are always +* available for field rules. +*/ +uint8_t lip[16 ];/* local IP address (IPv4 in [3:0]) */ +uint8_t fip[16 ];/* foreign IP address (IPv4 in [3:0]) */ +uint16_t lport;/* local port */ +uint16_t fport;/* foreign port */ +}; + +/* A filter ioctl command. +*/ +struct ch_filter_specification { +/* +* Administrative fields for filter. +*/ +uint32_t hitcnts:1 ;/* count filter hits in TCB */ +uint32_t prio:1 ;/* filter has priority over active/server */ + +/* Fundamental filter typing. This is the one element of filter +* matching that doesn't exist as a (value, mask) tuple. +*/ +uint32_t type:1 ;/* 0 => IPv4, 1 => IPv6 */ + +/* Packet dispatch information. Ingress packets which match the +* filter rules will be dropped, passed to the host or switched back +* out as egress packets. +*/ +uint32_t action:2 ;/* drop, pass, switch */ + +uint32_t rpttid:1 ;/* report TID in RSS hash field */ + +uint32_t dirsteer:1 ;/* 0 => RSS, 1 => steer to iq */ +uint32_t iq:10 ;/* ingress queue */ + +uint32_t maskhash:1 ;/* dirsteer=0: store RSS hash in TCB */ +uint32_t dirsteerhash:1 ;/* dirsteer=1: 0 => TCB contains RSS hash */ +/* 1 => TCB contains IQ ID */ + +/* Switch proxy/rewrite fields. An ingress packet which matches a +* filter with "switch" set will be looped back out as an egress +* packet -- potentially with some Ethernet header rewriting. +*/ +uint32_t eport:2 ;/* egress port to switch packet out */ +uint32_t newdmac:1 ;/* rewrite destination MAC address */ +uint32_t newsmac:1 ;/* rewrite source MAC address */ +uint32_t newvlan:2 ;/* rewrite VLAN Tag */ +uint8_t dmac[ETH_ALEN ];/* new destination MAC address */ +uint8_t smac[ETH_ALEN ];/* new source MAC address */ +uint16_t vlan;/* VLAN Tag to insert */ + +/* Filter rule value/mask pairs. +*/ +struct ch_filter_tuple val; +struct ch_filter_tuple mask; +}; + +enum { +FILTER_PASS =0 ,/* default */ +FILTER_DROP , +FILTER_SWITCH +}; + +enum { +VLAN_NOCHANGE =0 ,/* default */ +VLAN_REMOVE , +VLAN_INSERT , +VLAN_REWRITE +}; +static inline u32 t4_read_reg (struct adapter *adap,u32 reg_addr) {return readl (adap->regs + reg_addr);
@@ -701,6 +827,12 @@ static inline int t4_wr_mbox_ns(struct adapter *adap, int mbox, const void *cmd,void t4_write_indirect (struct adapter *adap,unsigned int addr_reg,unsigned int data_reg,const u32 *vals,unsigned int nregs,unsigned int start_idx); +void t4_read_indirect (struct adapter *adap,unsigned int addr_reg, +unsigned int data_reg,u32 *vals,unsigned int nregs, +unsigned int start_idx); + +struct fw_filter_wr ; +void t4_intr_enable (struct adapter *adapter);void t4_intr_disable (struct adapter *adapter);int t4_slow_intr_handler (struct adapter *adapter);
@@ -737,6 +869,8 @@ void t4_tp_get_tcp_stats(struct adapter *adap, struct tp_tcp_stats *v4,void t4_load_mtus (struct adapter *adap,const unsigned short *mtus,const unsigned short *alpha,const unsigned short *beta); +void t4_mk_filtdelwr (unsigned int ftid,struct fw_filter_wr *wr,int qid); +void t4_wol_magic_enable (struct adapter *adap,unsigned int port,const u8 *addr); int t4_wol_pat_enable(struct adapter *adap, unsigned int port, unsigned int map,
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +296 -5
370 lines not on this page · raw message
drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h +2 -0
@@ -97,7 +97,9 @@ struct tid_info {union aopen_entry *atid_tab;unsigned int natids; +unsigned int atid_base; +struct filter_entry *ftid_tab;unsigned int nftids;unsigned int ftid_base;unsigned int aftid_base;
drivers/net/ethernet/chelsio/cxgb4/l2t.c +33 -0
@@ -484,6 +484,39 @@ void t4_l2t_update(struct adapter *adap, struct neighbour *neigh)handle_failed_resolution (adap, arpq); } +/* +* Allocate an L2T entry for use by a switching rule. Such need to be +* explicitly freed and while busy they are not on any hash chain, so normal +* address resolution updates do not see them. +*/ +struct l2t_entry *t4_l2t_alloc_switching (struct l2t_data *d) +{ +struct l2t_entry *e; + +write_lock_bh (&d->lock); + e =alloc_l2e (d); +if (e) { +spin_lock (&e->lock);/* avoid race with t4_l2t_free */ + e->state =L2T_STATE_SWITCHING ; +atomic_set (&e->refcnt,1 ); +spin_unlock (&e->lock); + } +write_unlock_bh (&d->lock); +return e; +} + +/* Sets/updates the contents of a switching L2T entry that has been allocated +* with an earlier call to @t4_l2t_alloc_switching. +*/ +int t4_l2t_set_switching (struct adapter *adap,struct l2t_entry *e,u16 vlan, +u8 port,u8 *eth_addr) +{ + e->vlan = vlan; + e->lport = port; +memcpy (e->dmac, eth_addr,ETH_ALEN ); +return write_l2e (adap, e,0 ); +} +struct l2t_data *t4_init_l2t (void ) {int i;
drivers/net/ethernet/chelsio/cxgb4/l2t.h +3 -0
@@ -100,6 +100,9 @@ struct l2t_entry *cxgb4_l2t_get(struct l2t_data *d, struct neighbour *neigh, unsigned int priority);void t4_l2t_update (struct adapter *adap,struct neighbour *neigh); +struct l2t_entry *t4_l2t_alloc_switching (struct l2t_data *d); +int t4_l2t_set_switching (struct adapter *adap,struct l2t_entry *e,u16 vlan, +u8 port,u8 *eth_addr);struct l2t_data *t4_init_l2t (void );void do_l2t_write_rpl (struct adapter *p,const struct cpl_l2t_write_rpl *rpl);
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +22 -1
@@ -109,7 +109,7 @@ void t4_set_reg_field(struct adapter *adapter, unsigned int addr, u32 mask,* Reads registers that are accessed indirectly through an address/data * register pair. */ -static void t4_read_indirect (struct adapter *adap,unsigned int addr_reg, +void t4_read_indirect (struct adapter *adap,unsigned int addr_reg,unsigned int data_reg,u32 *vals,unsigned int nregs,unsigned int start_idx) {
@@ -2268,6 +2268,27 @@ int t4_wol_pat_enable(struct adapter *adap, unsigned int port, unsigned int map,return 0 ; } +/* +* t4_mk_filtdelwr - create a delete filter WR +* @ftid: the filter ID +* @wr: the filter work request to populate +* @qid: ingress queue to receive the delete notification +* +* Creates a filter work request to delete the supplied filter. If @qid is +* negative the delete notification is suppressed. +*/ +void t4_mk_filtdelwr (unsigned int ftid,struct fw_filter_wr *wr,int qid) +{ +memset (wr,0 ,sizeof (*wr)); + wr->op_pkd =htonl (FW_WR_OP (FW_FILTER_WR )); + wr->len16_pkd =htonl (FW_WR_LEN16 (sizeof (*wr) /16 )); + wr->tid_to_iq =htonl (V_FW_FILTER_WR_TID (ftid) | +V_FW_FILTER_WR_NOREPLY (qid <0 )); + wr->del_filter_to_l2tix =htonl (F_FW_FILTER_WR_DEL_FILTER ); +if (qid >=0 ) + wr->rx_chan_rx_rpl_iq =htons (V_FW_FILTER_WR_RX_RPL_IQ (qid)); +} +#define INIT_CMD (var, cmd, rd_wr) do { \ (var).op_to_write = htonl(FW_CMD_OP(FW_##cmd##_CMD) | \ FW_CMD_REQUEST | FW_CMD_##rd_wr); \
drivers/net/ethernet/chelsio/cxgb4/t4_msg.h +1 -0
@@ -332,6 +332,7 @@ struct cpl_set_tcb_field {__be16 word_cookie;#define TCB_WORD (x) ((x) << 0)#define TCB_COOKIE (x) ((x) << 5) +#define GET_TCB_COOKIE (x) (((x) >> 5) & 7)__be64 mask;__be64 val; };
drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h +279 -0
291 lines not on this page · raw message
Signature · 6 lines
1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 2/5 cxgb4: Add LE hash collision bug fix path in LLD driver
In reply to Vipul PandyaIt supports establishing passive open connection through firmware filter work request. Passive open connection will go through this path as now instead of listening server we create a server filter which will redirect the incoming SYN packet to the offload queue.
It divides filter region into regular filters and server filter portion. It introduces new server filter region which will be exclusively used for creating server filters. This region will not overlap with regular filter region.
It provides new API cxgb4_alloc_sftid in LLD for getting stid in case of LE hash collision path. This new stid will be used to open server filter in the filter region.
---
V2: Changed commenting style from kernel-doc format('/**') to normal
V3: Resending the whole patch series again with the missing patches in V2
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 4 + drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 150 +++++++++++++++++++++- drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h | 15 ++- drivers/net/ethernet/chelsio/cxgb4/t4_regs.h | 33 +++++ 4 files changed, 193 insertions(+), 9 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +4 -0
@@ -35,6 +35,8 @@#ifndef __CXGB4_H__#define __CXGB4_H__ +#include "t4_hw.h" +#include <linux/bitops.h> #include <linux/cache.h> #include <linux/interrupt.h>
@@ -212,6 +214,8 @@ struct tp_err_stats {struct tp_params {unsigned int ntxchan;/* # of Tx channels */ unsigned int tre;/* log2 of core clocks per TP tick */ +unsigned short tx_modq_map;/* TX modulation scheduler queue to */ +/* channel map */ uint32_t dack_re;/* DACK timer resolution */ unsigned short tx_modq[NCHAN ];/* channel to modulation queue map */
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +143 -7
218 lines not on this page · raw message
drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h +13 -2
@@ -131,7 +131,7 @@ static inline void *lookup_atid(const struct tid_info *t, unsigned int atid)static inline void *lookup_stid (const struct tid_info *t,unsigned int stid) { stid -= t->stid_base; -return stid < t->nstids ? t->stid_tab[stid].data :NULL ; +return stid < (t->nstids + t->nsftids) ? t->stid_tab[stid].data :NULL ; } static inline void cxgb4_insert_tid(struct tid_info *t, void *data,
@@ -143,6 +143,7 @@ static inline void cxgb4_insert_tid(struct tid_info *t, void *data,int cxgb4_alloc_atid (struct tid_info *t,void *data);int cxgb4_alloc_stid (struct tid_info *t,int family,void *data); +int cxgb4_alloc_sftid (struct tid_info *t,int family,void *data);void cxgb4_free_atid (struct tid_info *t,unsigned int atid);void cxgb4_free_stid (struct tid_info *t,unsigned int stid,int family);void cxgb4_remove_tid (struct tid_info *t,unsigned int qid,unsigned int tid);
@@ -151,7 +152,10 @@ struct in6_addr;int cxgb4_create_server (const struct net_device *dev,unsigned int stid,__be32 sip,__be16 sport,unsigned int queue); - +int cxgb4_create_server_filter (const struct net_device *dev,unsigned int stid, +__be32 sip,__be16 sport,unsigned int queue); +int cxgb4_remove_server_filter (const struct net_device *dev,unsigned int stid, +unsigned int queue,bool ipv6);static inline void set_wr_txq (struct sk_buff *skb,int prio,int queue) {skb_set_queue_mapping (skb, (queue <<1 ) | prio);
@@ -223,9 +227,16 @@ struct cxgb4_lld_info {unsigned int iscsi_iolen;/* iSCSI max I/O length */ unsigned short udb_density;/* # of user DB/page */ unsigned short ucq_density;/* # of user CQs/page */ +unsigned short filt_mode;/* filter optional components */ +unsigned short tx_modq[NCHAN ];/* maps each tx channel to a */ +/* scheduler queue */ void __iomem *gts_reg;/* address of GTS register */ void __iomem *db_reg;/* address of kernel doorbell */ int dbfifo_int_thresh;/* doorbell fifo int threshold */ +unsigned int sge_pktshift;/* Padding between CPL and */ +/* packet data */ +bool enable_fw_ofld_conn;/* Enable connection through fw */ +/* WR */ };struct cxgb4_uld_info {
drivers/net/ethernet/chelsio/cxgb4/t4_regs.h +33 -0
@@ -1032,4 +1032,37 @@#define ADDRESS (x) ((x) << ADDRESS_SHIFT)#define XGMAC_PORT_INT_CAUSE 0x10dc + +#define A_TP_TX_MOD_QUEUE_REQ_MAP 0x7e28 + +#define A_TP_TX_MOD_CHANNEL_WEIGHT 0x7e34 + +#define S_TX_MOD_QUEUE_REQ_MAP 0 +#define M_TX_MOD_QUEUE_REQ_MAP 0xffffU +#define V_TX_MOD_QUEUE_REQ_MAP (x) ((x) << S_TX_MOD_QUEUE_REQ_MAP) + +#define A_TP_TX_MOD_QUEUE_WEIGHT0 0x7e30 + +#define S_TX_MODQ_WEIGHT3 24 +#define M_TX_MODQ_WEIGHT3 0xffU +#define V_TX_MODQ_WEIGHT3 (x) ((x) << S_TX_MODQ_WEIGHT3) + +#define S_TX_MODQ_WEIGHT2 16 +#define M_TX_MODQ_WEIGHT2 0xffU +#define V_TX_MODQ_WEIGHT2 (x) ((x) << S_TX_MODQ_WEIGHT2) + +#define S_TX_MODQ_WEIGHT1 8 +#define M_TX_MODQ_WEIGHT1 0xffU +#define V_TX_MODQ_WEIGHT1 (x) ((x) << S_TX_MODQ_WEIGHT1) + +#define S_TX_MODQ_WEIGHT0 0 +#define M_TX_MODQ_WEIGHT0 0xffU +#define V_TX_MODQ_WEIGHT0 (x) ((x) << S_TX_MODQ_WEIGHT0) + +#define A_TP_TX_SCHED_HDR 0x23 + +#define A_TP_TX_SCHED_FIFO 0x24 + +#define A_TP_TX_SCHED_PCMD 0x25 +#endif /* __T4_REGS_H */
Signature · 1 line
1.7.1
PATCH v3 3/5 RDMA/cxgb4: Fix LE hash collision bug for active open connection
In reply to Vipul PandyaIt enables establishing active open connection using fw_ofld_connection work request when cpl_act_open_rpl says TCAM full error which may be because of LE hash collision. Current support is only for IPv4 active open connections.
Sets ntuple bits in active open requests. For T4 firmware greater than 1.4.10.0 ntuple bits are required to be set.
Adds nocong and enable_ecn module parameter options.
---
V2: Changed commenting style from kernel-doc format('/**') to normal
V3: Resending the whole patch series again with the missing patches in V2
drivers/infiniband/hw/cxgb4/cm.c | 158 ++++++++++++++++++++++++- drivers/infiniband/hw/cxgb4/iw_cxgb4.h | 1 + drivers/net/ethernet/chelsio/cxgb4/t4_msg.h | 19 +++ drivers/net/ethernet/chelsio/cxgb4/t4_regs.h | 2 + drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h | 109 +++++++++++++++++ 5 files changed, 283 insertions(+), 6 deletions(-)
drivers/infiniband/hw/cxgb4/cm.c +152 -6
@@ -61,6 +61,14 @@ static char *states[] = { NULL, }; +static int nocong; +module_param (nocong, int,0644 ); +MODULE_PARM_DESC (nocong,"Turn of congestion control (default=0)" ); + +static int enable_ecn; +module_param (enable_ecn, int,0644 ); +MODULE_PARM_DESC (enable_ecn,"Enable ECN (default=0/disabled)" ); +static int dack_mode =1 ;module_param (dack_mode, int,0644 );MODULE_PARM_DESC (dack_mode,"Delayed ack mode (default=1)" );
@@ -441,6 +449,50 @@ static int send_abort(struct c4iw_ep *ep, struct sk_buff *skb, gfp_t gfp)return c4iw_l2t_send (&ep->com.dev->rdev, skb, ep->l2t); } +#define VLAN_NONE 0xfff +#define FILTER_SEL_VLAN_NONE 0xffff +#define FILTER_SEL_WIDTH_P_FC (3+1)/* port uses 3 bits, FCoE one bit */ +#define FILTER_SEL_WIDTH_VIN_P_FC \ + (6 + 7 + FILTER_SEL_WIDTH_P_FC)/* 6 bits are unused, VF uses 7 bits*/ +#define FILTER_SEL_WIDTH_TAG_P_FC \ + (3 + FILTER_SEL_WIDTH_VIN_P_FC)/* PF uses 3 bits */ +#define FILTER_SEL_WIDTH_VLD_TAG_P_FC (1 + FILTER_SEL_WIDTH_TAG_P_FC) + +static unsigned int select_ntuple (struct c4iw_dev *dev,struct dst_entry *dst, +struct l2t_entry *l2t) +{ +unsigned int ntuple =0 ; +u32 viid; + +switch (dev->rdev.lldi.filt_mode) { + +/* default filter mode */ +case HW_TPL_FR_MT_PR_IV_P_FC : +if (l2t->vlan ==VLAN_NONE ) + ntuple |=FILTER_SEL_VLAN_NONE <<FILTER_SEL_WIDTH_P_FC ; +else { + ntuple |= l2t->vlan <<FILTER_SEL_WIDTH_P_FC ; + ntuple |=1 <<FILTER_SEL_WIDTH_VLD_TAG_P_FC ; + } + ntuple |= l2t->lport <<S_PORT |IPPROTO_TCP << +FILTER_SEL_WIDTH_VLD_TAG_P_FC ; +break ; +case HW_TPL_FR_MT_PR_OV_P_FC : { + viid =cxgb4_port_viid (l2t->neigh->dev); + + ntuple |=FW_VIID_VIN_GET (viid) <<FILTER_SEL_WIDTH_P_FC ; + ntuple |=FW_VIID_PFN_GET (viid) <<FILTER_SEL_WIDTH_VIN_P_FC ; + ntuple |=FW_VIID_VIVLD_GET (viid) <<FILTER_SEL_WIDTH_TAG_P_FC ; + ntuple |= l2t->lport <<S_PORT |IPPROTO_TCP << +FILTER_SEL_WIDTH_VLD_TAG_P_FC ; +break ; + } +default : +break ; + } +return ntuple; +} +static int send_connect (struct c4iw_ep *ep) {struct cpl_act_open_req *req;
@@ -463,7 +515,8 @@ static int send_connect(struct c4iw_ep *ep)cxgb4_best_mtu (ep->com.dev->rdev.lldi.mtus, ep->mtu, &mtu_idx); wscale =compute_wscale (rcv_win); - opt0 =KEEP_ALIVE (1 ) | + opt0 = (nocong ?NO_CONG (1 ) :0 ) | +KEEP_ALIVE (1 ) |DELACK (1 ) |WND_SCALE (wscale) | MSS_IDX(mtu_idx) |
@@ -474,6 +527,7 @@ static int send_connect(struct c4iw_ep *ep)ULP_MODE (ULP_MODE_TCPDDP ) |RCV_BUFSIZ (rcv_win>>10 ); opt2 =RX_CHANNEL (0 ) | +CCTRL_ECN (enable_ecn) |RSS_QUEUE_VALID |RSS_QUEUE (ep->rss_qid);if (enable_tcp_timestamps) opt2 |=TSTAMPS_EN (1 );
@@ -492,7 +546,7 @@ static int send_connect(struct c4iw_ep *ep) req->local_ip = ep->com.local_addr.sin_addr.s_addr; req->peer_ip = ep->com.remote_addr.sin_addr.s_addr; req->opt0 =cpu_to_be64 (opt0); - req->params =0 ; + req->params =cpu_to_be32 (select_ntuple (ep->com.dev, ep->dst, ep->l2t)); req->opt2 =cpu_to_be32 (opt2);return c4iw_l2t_send (&ep->com.dev->rdev, skb, ep->l2t); }
@@ -1383,6 +1437,61 @@ static int abort_rpl(struct c4iw_dev *dev, struct sk_buff *skb)return 0 ; } +static void send_fw_act_open_req (struct c4iw_ep *ep,unsigned int atid) +{ +struct sk_buff *skb; +struct fw_ofld_connection_wr *req; +unsigned int mtu_idx; +int wscale; + + skb =get_skb (NULL ,sizeof (*req),GFP_KERNEL ); + req = (struct fw_ofld_connection_wr *)__skb_put (skb,sizeof (*req)); +memset (req,0 ,sizeof (*req)); + req->op_compl =htonl (V_WR_OP (FW_OFLD_CONNECTION_WR )); + req->len16_pkd =htonl (FW_WR_LEN16 (DIV_ROUND_UP (sizeof (*req),16 ))); + req->le.filter =cpu_to_be32 (select_ntuple (ep->com.dev, ep->dst, + ep->l2t)); + req->le.lport = ep->com.local_addr.sin_port; + req->le.pport = ep->com.remote_addr.sin_port; + req->le.u.ipv4.lip = ep->com.local_addr.sin_addr.s_addr; + req->le.u.ipv4.pip = ep->com.remote_addr.sin_addr.s_addr; + req->tcb.t_state_to_astid = +htonl (V_FW_OFLD_CONNECTION_WR_T_STATE (TCP_SYN_SENT ) | +V_FW_OFLD_CONNECTION_WR_ASTID (atid)); + req->tcb.cplrxdataack_cplpassacceptrpl = +htons (F_FW_OFLD_CONNECTION_WR_CPLRXDATAACK ); + req->tcb.tx_max = jiffies; +cxgb4_best_mtu (ep->com.dev->rdev.lldi.mtus, ep->mtu, &mtu_idx); + wscale =compute_wscale (rcv_win); + req->tcb.opt0 =TCAM_BYPASS (1 ) | + (nocong ?NO_CONG (1 ) :0 ) | +KEEP_ALIVE (1 ) | +DELACK (1 ) | +WND_SCALE (wscale) | +MSS_IDX (mtu_idx) | +L2T_IDX (ep->l2t->idx) | +TX_CHAN (ep->tx_chan) | +SMAC_SEL (ep->smac_idx) | +DSCP (ep->tos) | +ULP_MODE (ULP_MODE_TCPDDP ) | +RCV_BUFSIZ (rcv_win >>10 ); + req->tcb.opt2 =PACE (1 ) | +TX_QUEUE (ep->com.dev->rdev.lldi.tx_modq[ep->tx_chan]) | +RX_CHANNEL (0 ) | +CCTRL_ECN (enable_ecn) | +RSS_QUEUE_VALID |RSS_QUEUE (ep->rss_qid); +if (enable_tcp_timestamps) + req->tcb.opt2 |=TSTAMPS_EN (1 ); +if (enable_tcp_sack) + req->tcb.opt2 |=SACK_EN (1 ); +if (wscale && enable_tcp_window_scaling) + req->tcb.opt2 |=WND_SCALE_EN (1 ); + req->tcb.opt0 =cpu_to_be64 (req->tcb.opt0); + req->tcb.opt2 =cpu_to_be32 (req->tcb.opt2); +set_wr_txq (skb,CPL_PRIORITY_CONTROL ,0 ); +c4iw_l2t_send (&ep->com.dev->rdev, skb, ep->l2t); +} +/* * Return whether a failed active open has allocated a TID */
@@ -1419,6 +1528,14 @@ static int act_open_rpl(struct c4iw_dev *dev, struct sk_buff *skb)case CPL_ERR_CONN_RESET :case CPL_ERR_CONN_TIMEDOUT :break ; +case CPL_ERR_TCAM_FULL : +mutex_lock (&dev->rdev.stats.lock); + dev->rdev.stats.tcam_full++; +mutex_unlock (&dev->rdev.stats.lock); +send_fw_act_open_req (ep, +GET_TID_TID (GET_AOPEN_ATID (ntohl (rpl->atid_status)))); +return 0 ; +break ;default : printk(KERN_INFO MOD "Active open failure - " "atid %u status %u errno %d %pI4:%u->%pI4:%u\n",
@@ -1510,14 +1627,15 @@ static void accept_cr(struct c4iw_ep *ep, __be32 peer_ip, struct sk_buff *skb,skb_get (skb);cxgb4_best_mtu (ep->com.dev->rdev.lldi.mtus, ep->mtu, &mtu_idx); wscale =compute_wscale (rcv_win); - opt0 =KEEP_ALIVE (1 ) | + opt0 = (nocong ?NO_CONG (1 ) :0 ) | +KEEP_ALIVE (1 ) |DELACK (1 ) |WND_SCALE (wscale) |MSS_IDX (mtu_idx) |L2T_IDX (ep->l2t->idx) |TX_CHAN (ep->tx_chan) |SMAC_SEL (ep->smac_idx) | -DSCP (ep->tos) | +DSCP (ep->tos >>2 ) |ULP_MODE (ULP_MODE_TCPDDP ) |RCV_BUFSIZ (rcv_win>>10 ); opt2 = RX_CHANNEL(0) |
@@ -1529,6 +1647,15 @@ static void accept_cr(struct c4iw_ep *ep, __be32 peer_ip, struct sk_buff *skb, opt2 |=SACK_EN (1 );if (wscale && enable_tcp_window_scaling) opt2 |=WND_SCALE_EN (1 ); +if (enable_ecn) { +const struct tcphdr *tcph; +u32 hlen =ntohl (req->hdr_len); + + tcph = (const void *)(req +1 ) +G_ETH_HDR_LEN (hlen) + +G_IP_HDR_LEN (hlen); +if (tcph->ece && tcph->cwr) + opt2 |=CCTRL_ECN (1 ); + } rpl =cplhdr (skb);INIT_TP_WR (rpl, ep->hwtid);
@@ -2647,11 +2774,14 @@ static int fw6_msg(struct c4iw_dev *dev, struct sk_buff *skb)struct cpl_fw6_msg *rpl =cplhdr (skb);struct c4iw_wr_wait *wr_waitp;int ret; +u8 opcode; +struct cpl_fw6_msg_ofld_connection_wr_rpl *req; +struct c4iw_ep *ep;PDBG ("%s type %u\n" , __func__, rpl->type);switch (rpl->type) { -case 1 : +case FW6_TYPE_WR_RPL : ret = (int )((be64_to_cpu (rpl->data[0 ]) >>8 ) &0xff ); wr_waitp = (struct c4iw_wr_wait *)(__force unsigned long ) rpl->data[1 ];PDBG ("%s wr_waitp %p ret %u\n" , __func__, wr_waitp, ret);
@@ -2659,9 +2789,25 @@ static int fw6_msg(struct c4iw_dev *dev, struct sk_buff *skb)c4iw_wake_up (wr_waitp, ret ? -ret :0 );kfree_skb (skb);break ; -case 2 : +case FW6_TYPE_CQE :sched (dev, skb);break ; +case FW6_TYPE_OFLD_CONNECTION_WR_RPL : + opcode = *(const u8 *)rpl->data; +if (opcode ==FW_OFLD_CONNECTION_WR ) { + req = + (struct cpl_fw6_msg_ofld_connection_wr_rpl *)rpl->data; +if (req->t_state ==TCP_SYN_SENT + && (req->retval ==FW_ENOMEM + || req->retval ==FW_EADDRINUSE )) { + ep = (struct c4iw_ep *) +lookup_atid (dev->rdev.lldi.tids, + req->tid); +c4iw_l2t_send (&dev->rdev, skb, ep->l2t); +return 0 ; + } + } +break ;default : printk(KERN_ERR MOD "%s unexpected fw6 msg type %u\n", __func__, rpl->type);
drivers/infiniband/hw/cxgb4/iw_cxgb4.h +1 -0
@@ -130,6 +130,7 @@ struct c4iw_stats {u64 db_empty;u64 db_drop;u64 db_state_transitions; +u64 tcam_full; };struct c4iw_rdev {
drivers/net/ethernet/chelsio/cxgb4/t4_msg.h +19 -0
@@ -193,6 +193,10 @@ struct work_request_hdr {__be64 wr_lo; }; +/* wr_hi fields */ +#define S_WR_OP 24 +#define V_WR_OP (x) ((__u64)(x) << S_WR_OP) +#define WR_HDR struct work_request_hdr wrstruct cpl_pass_open_req {
@@ -204,12 +208,14 @@ struct cpl_pass_open_req {__be32 peer_ip;__be64 opt0;#define TX_CHAN (x) ((x) << 2) +#define NO_CONG (x) ((x) << 4)#define DELACK (x) ((x) << 5)#define ULP_MODE (x) ((x) << 8)#define RCV_BUFSIZ (x) ((x) << 12)#define DSCP (x) ((x) << 22)#define SMAC_SEL (x) ((u64)(x) << 28)#define L2T_IDX (x) ((u64)(x) << 36) +#define TCAM_BYPASS (x) ((u64)(x) << 48)#define NAGLE (x) ((u64)(x) << 49)#define WND_SCALE (x) ((u64)(x) << 50)#define KEEP_ALIVE (x) ((u64)(x) << 54)
@@ -247,8 +253,10 @@ struct cpl_pass_accept_rpl {#define RSS_QUEUE_VALID (1 << 10)#define RX_COALESCE_VALID (x) ((x) << 11)#define RX_COALESCE (x) ((x) << 12) +#define PACE (x) ((x) << 16)#define TX_QUEUE (x) ((x) << 23)#define RX_CHANNEL (x) ((x) << 26) +#define CCTRL_ECN (x) ((x) << 27)#define WND_SCALE_EN (x) ((x) << 28)#define TSTAMPS_EN (x) ((x) << 29)#define SACK_EN (x) ((x) << 30)
@@ -635,6 +643,17 @@ struct cpl_fw6_msg {/* cpl_fw6_msg.type values */ enum {FW6_TYPE_CMD_RPL =0 , +FW6_TYPE_WR_RPL =1 , +FW6_TYPE_CQE =2 , +FW6_TYPE_OFLD_CONNECTION_WR_RPL =3 , +}; + +struct cpl_fw6_msg_ofld_connection_wr_rpl { +__u64 cookie; +__be32 tid;/* or atid in case of active failure */ +__u8 t_state; +__u8 retval; +__u8 rsvd[2 ]; };enum {
drivers/net/ethernet/chelsio/cxgb4/t4_regs.h +2 -0
@@ -1065,4 +1065,6 @@#define A_TP_TX_SCHED_PCMD 0x25 +#define S_PORT 1 +#endif /* __T4_REGS_H */
drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h +109 -0
133 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v3 4/5 RDMA/cxgb4: Fix LE hash collision bug for passive open connection
In reply to Vipul PandyaIt establishes passive open connection through firmware work request. Passive open connection will go through this path as now instead of listening server we create a server filter which will redirect the incoming SYN packet to the offload queue. After this driver tries to establish the connection using firmware work request.
---
V2: Changed commenting style from kernel-doc format('/**') to normal
V3: Resending the whole patch series again with the missing patches in V2
drivers/infiniband/hw/cxgb4/cm.c | 411 ++++++++++++++++++++--- drivers/infiniband/hw/cxgb4/device.c | 85 +++++- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 9 + drivers/net/ethernet/chelsio/cxgb4/t4_msg.h | 46 +++ 4 files changed, 496 insertions(+), 55 deletions(-)
drivers/infiniband/hw/cxgb4/cm.c +362 -49
@@ -38,10 +38,12 @@#include <linux/inetdevice.h> #include <linux/ip.h> #include <linux/tcp.h> +#include <linux/if_vlan.h> #include <net/neighbour.h> #include <net/netevent.h> #include <net/route.h> +#include <net/tcp.h> #include "iw_cxgb4.h"
@@ -1569,13 +1571,14 @@ static int pass_open_rpl(struct c4iw_dev *dev, struct sk_buff *skb)struct c4iw_listen_ep *ep =lookup_stid (t, stid);if (!ep) { - printk(KERN_ERR MOD "stid %d lookup failure!\n", stid); -return 0 ; +PDBG ("%s stid %d lookup failure!\n" , __func__, stid); + goto out; }PDBG ("%s ep %p status %d error %d\n" , __func__, ep, rpl->status,status2errno (rpl->status));c4iw_wake_up (&ep->com.wr_wait,status2errno (rpl->status)); +out:return 0 ; }
@@ -1779,15 +1782,23 @@ static int pass_accept_req(struct c4iw_dev *dev, struct sk_buff *skb)unsigned int hwtid =GET_TID (req);struct dst_entry *dst;struct rtable *rt; -__be32 local_ip, peer_ip; +__be32 local_ip, peer_ip =0 ;__be16 local_port, peer_port;int err; +u16 peer_mss =ntohs (req->tcpopt.mss); parent_ep =lookup_stid (t, stid); -PDBG ("%s parent ep %p tid %u\n" , __func__, parent_ep, hwtid); - +if (!parent_ep) { +PDBG ("%s connect request on invalid stid %d\n" , __func__, stid); + goto reject; + }get_4tuple (req, &local_ip, &peer_ip, &local_port, &peer_port); +PDBG ("%s parent ep %p hwtid %u laddr 0x%x raddr 0x%x lport %d " \ +"rport %d peer_mss %d\n" , __func__, parent_ep, hwtid, +ntohl (local_ip),ntohl (peer_ip),ntohs (local_port), +ntohs (peer_port), peer_mss); +if (state_read (&parent_ep->com) !=LISTEN ) {printk (KERN_ERR "%s - listening ep not in LISTEN\n" , __func__);
@@ -1821,6 +1832,9 @@ static int pass_accept_req(struct c4iw_dev *dev, struct sk_buff *skb) goto reject; } +if (peer_mss && child_ep->mtu > (peer_mss +40 )) + child_ep->mtu = peer_mss +40 ; +state_set (&child_ep->com,CONNECTING ); child_ep->com.dev = dev; child_ep->com.cm_id =NULL ;
@@ -1861,6 +1875,9 @@ static int pass_establish(struct c4iw_dev *dev, struct sk_buff *skb) ep->snd_seq =be32_to_cpu (req->snd_isn); ep->rcv_seq =be32_to_cpu (req->rcv_isn); +PDBG ("%s ep %p hwtid %u tcp_opt 0x%02x\n" , __func__, ep, tid, +ntohs (req->tcp_opt)); +set_emss (ep,ntohs (req->tcp_opt));dst_confirm (ep->dst);
@@ -2478,7 +2495,6 @@ int c4iw_create_listen(struct iw_cm_id *cm_id, int backlog)struct c4iw_dev *dev =to_c4iw_dev (cm_id->device);struct c4iw_listen_ep *ep; -might_sleep (); ep =alloc_ep (sizeof (*ep),GFP_KERNEL );
@@ -2497,30 +2513,49 @@ int c4iw_create_listen(struct iw_cm_id *cm_id, int backlog)/* * Allocate a server TID. */ - ep->stid =cxgb4_alloc_stid (dev->rdev.lldi.tids,PF_INET , ep); +if (dev->rdev.lldi.enable_fw_ofld_conn) + ep->stid =cxgb4_alloc_sftid (dev->rdev.lldi.tids,PF_INET , ep); +else + ep->stid =cxgb4_alloc_stid (dev->rdev.lldi.tids,PF_INET , ep); +if (ep->stid ==-1 ) { printk(KERN_ERR MOD "%s - cannot alloc stid.\n", __func__); err = -ENOMEM ; goto fail2; } -state_set (&ep->com,LISTEN ); -c4iw_init_wr_wait (&ep->com.wr_wait); - err =cxgb4_create_server (ep->com.dev->rdev.lldi.ports[0 ], ep->stid, - ep->com.local_addr.sin_addr.s_addr, - ep->com.local_addr.sin_port, - ep->com.dev->rdev.lldi.rxq_ids[0 ]); -if (err) - goto fail3; - -/* wait for pass_open_rpl */ - err =c4iw_wait_for_reply (&ep->com.dev->rdev, &ep->com.wr_wait,0 ,0 , - __func__); +if (dev->rdev.lldi.enable_fw_ofld_conn) { +do { + err =cxgb4_create_server_filter ( + ep->com.dev->rdev.lldi.ports[0 ], ep->stid, + ep->com.local_addr.sin_addr.s_addr, + ep->com.local_addr.sin_port, + ep->com.dev->rdev.lldi.rxq_ids[0 ]); +if (err == -EBUSY ) { +set_current_state (TASK_UNINTERRUPTIBLE ); +schedule_timeout (usecs_to_jiffies (100 )); + } + }while (err == -EBUSY ); + }else { +c4iw_init_wr_wait (&ep->com.wr_wait); + err =cxgb4_create_server (ep->com.dev->rdev.lldi.ports[0 ], + ep->stid, ep->com.local_addr.sin_addr.s_addr, + ep->com.local_addr.sin_port, + ep->com.dev->rdev.lldi.rxq_ids[0 ]); +if (!err) + err =c4iw_wait_for_reply (&ep->com.dev->rdev, + &ep->com.wr_wait, +0 ,0 , __func__); + }if (!err) { cm_id->provider_data = ep; goto out; } -fail3: +pr_err ("%s cxgb4_create_server/filter failed err %d " \ +"stid %d laddr %08x lport %d\n" , \ + __func__, err, ep->stid, +ntohl (ep->com.local_addr.sin_addr.s_addr), +ntohs (ep->com.local_addr.sin_port));cxgb4_free_stid (ep->com.dev->rdev.lldi.tids, ep->stid,PF_INET ); fail2: cm_id->rem_ref (cm_id);
@@ -2539,12 +2574,18 @@ int c4iw_destroy_listen(struct iw_cm_id *cm_id)might_sleep ();state_set (&ep->com,DEAD ); -c4iw_init_wr_wait (&ep->com.wr_wait); - err =listen_stop (ep); -if (err) - goto done; - err =c4iw_wait_for_reply (&ep->com.dev->rdev, &ep->com.wr_wait,0 ,0 , - __func__); +if (ep->com.dev->rdev.lldi.enable_fw_ofld_conn) { + err =cxgb4_remove_server_filter ( + ep->com.dev->rdev.lldi.ports[0 ], ep->stid, + ep->com.dev->rdev.lldi.rxq_ids[0 ],0 ); + }else { +c4iw_init_wr_wait (&ep->com.wr_wait); + err =listen_stop (ep); +if (err) + goto done; + err =c4iw_wait_for_reply (&ep->com.dev->rdev, &ep->com.wr_wait, +0 ,0 , __func__); + }cxgb4_free_stid (ep->com.dev->rdev.lldi.tids, ep->stid,PF_INET ); done: cm_id->rem_ref (cm_id);
@@ -2621,10 +2662,298 @@ int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp)return ret; } -static int async_event (struct c4iw_dev *dev,struct sk_buff *skb) +static void active_ofld_conn_reply (struct c4iw_dev *dev,struct sk_buff *skb, +struct cpl_fw6_msg_ofld_connection_wr_rpl *req) +{ +struct c4iw_ep *ep; + + ep = (struct c4iw_ep *)lookup_atid (dev->rdev.lldi.tids, req->tid); +if (!ep) +return ; + +switch (req->retval) { +case FW_ENOMEM : +case FW_EADDRINUSE : +PDBG ("%s ofld conn wr ret %d\n" , __func__, req->retval); +break ; +default : +pr_info ("%s unexpected ofld conn wr retval %d\n" , + __func__, req->retval); +break ; + } +connect_reply_upcall (ep,status2errno (req->retval)); +} + +static void passive_ofld_conn_reply (struct c4iw_dev *dev,struct sk_buff *skb, +struct cpl_fw6_msg_ofld_connection_wr_rpl *req) +{ +struct sk_buff *rpl_skb; +struct cpl_pass_accept_req *cpl; +int ret; + + rpl_skb = (struct sk_buff *)cpu_to_be64 (req->cookie); +BUG_ON (!rpl_skb); +if (req->retval) { +PDBG ("%s passive open failure %d\n" , __func__, req->retval); +kfree_skb (rpl_skb); + }else { + cpl = (struct cpl_pass_accept_req *)cplhdr (rpl_skb); +OPCODE_TID (cpl) =htonl (MK_OPCODE_TID (CPL_PASS_ACCEPT_REQ , +htonl (req->tid))); + ret =pass_accept_req (dev, rpl_skb); +if (!ret) +kfree_skb (rpl_skb); + } +return ; +} + +static int deferred_fw6_msg (struct c4iw_dev *dev,struct sk_buff *skb) {struct cpl_fw6_msg *rpl =cplhdr (skb); -c4iw_ev_dispatch (dev, (struct t4_cqe *)&rpl->data[0 ]); +struct cpl_fw6_msg_ofld_connection_wr_rpl *req; + +switch (rpl->type) { +case FW6_TYPE_CQE : +c4iw_ev_dispatch (dev, (struct t4_cqe *)&rpl->data[0 ]); +break ; +case FW6_TYPE_OFLD_CONNECTION_WR_RPL : + req = (struct cpl_fw6_msg_ofld_connection_wr_rpl *)rpl->data; +switch (req->t_state) { +case TCP_SYN_SENT : +active_ofld_conn_reply (dev, skb, req); +break ; +case TCP_SYN_RECV : +passive_ofld_conn_reply (dev, skb, req); +break ; +default : +pr_err ("%s unexpected ofld conn wr state %d\n" , + __func__, req->t_state); +break ; + } +break ; + } +return 0 ; +} + +static void build_cpl_pass_accept_req (struct sk_buff *skb,int stid ,u8 tos) +{ +u32 l2info; +u16 vlantag, len, hdr_len; +u8 intf; +struct cpl_rx_pkt *cpl =cplhdr (skb); +struct cpl_pass_accept_req *req; +struct tcp_options_received tmp_opt; + +/* Store values from cpl_rx_pkt in temporary location. */ + vlantag = cpl->vlan; + len = cpl->len; + l2info = cpl->l2info; + hdr_len = cpl->hdr_len; + intf = cpl->iff; + +__skb_pull (skb,sizeof (*req) +sizeof (struct rss_header )); + +/* We need to parse the TCP options from SYN packet. +* to generate cpl_pass_accept_req. +*/ +memset (&tmp_opt,0 ,sizeof (tmp_opt)); +tcp_clear_options (&tmp_opt); +tcp_parse_options (skb, &tmp_opt,0 ,0 ,NULL ); + + req = (struct cpl_pass_accept_req *)__skb_push (skb,sizeof (*req)); +memset (req,0 ,sizeof (*req)); + req->l2info =cpu_to_be16 (V_SYN_INTF (intf) | +V_SYN_MAC_IDX (G_RX_MACIDX (htonl (l2info))) | +F_SYN_XACT_MATCH ); + req->hdr_len =cpu_to_be32 (V_SYN_RX_CHAN (G_RX_CHAN (htonl (l2info))) | +V_TCP_HDR_LEN (G_RX_TCPHDR_LEN (htons (hdr_len))) | +V_IP_HDR_LEN (G_RX_IPHDR_LEN (htons (hdr_len))) | +V_ETH_HDR_LEN (G_RX_ETHHDR_LEN (htonl (l2info)))); + req->vlan = vlantag; + req->len = len; + req->tos_stid =cpu_to_be32 (PASS_OPEN_TID (stid) | +PASS_OPEN_TOS (tos)); + req->tcpopt.mss =htons (tmp_opt.mss_clamp); +if (tmp_opt.wscale_ok) + req->tcpopt.wsf = tmp_opt.snd_wscale; + req->tcpopt.tstamp = tmp_opt.saw_tstamp; +if (tmp_opt.sack_ok) + req->tcpopt.sack =1 ; +OPCODE_TID (req) =htonl (MK_OPCODE_TID (CPL_PASS_ACCEPT_REQ ,0 )); +return ; +} + +static void send_fw_pass_open_req (struct c4iw_dev *dev,struct sk_buff *skb, +__be32 laddr,__be16 lport, +__be32 raddr,__be16 rport, +u32 rcv_isn,u32 filter,u16 window, +u32 rss_qid,u8 port_id) +{ +struct sk_buff *req_skb; +struct fw_ofld_connection_wr *req; +struct cpl_pass_accept_req *cpl =cplhdr (skb); + + req_skb =alloc_skb (sizeof (struct fw_ofld_connection_wr ),GFP_KERNEL ); + req = (struct fw_ofld_connection_wr *)__skb_put (req_skb,sizeof (*req)); +memset (req,0 ,sizeof (*req)); + 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->le.version_cpl =htonl (F_FW_OFLD_CONNECTION_WR_CPL ); + req->le.filter = filter; + req->le.lport = lport; + req->le.pport = rport; + req->le.u.ipv4.lip = laddr; + req->le.u.ipv4.pip = raddr; + req->tcb.rcv_nxt =htonl (rcv_isn +1 ); + req->tcb.rcv_adv =htons (window); + req->tcb.t_state_to_astid = +htonl (V_FW_OFLD_CONNECTION_WR_T_STATE (TCP_SYN_RECV ) | +V_FW_OFLD_CONNECTION_WR_RCV_SCALE (cpl->tcpopt.wsf) | +V_FW_OFLD_CONNECTION_WR_ASTID ( +GET_PASS_OPEN_TID (ntohl (cpl->tos_stid)))); + +/* +* We store the qid in opt2 which will be used by the firmware +* to send us the wr response. +*/ + req->tcb.opt2 =htonl (V_RSS_QUEUE (rss_qid)); + +/* +* We initialize the MSS index in TCB to 0xF. +* So that when driver sends cpl_pass_accept_rpl +* TCB picks up the correct value. If this was 0 +* TP will ignore any value > 0 for MSS index. +*/ + req->tcb.opt0 =cpu_to_be64 (V_MSS_IDX (0xF )); + req->cookie =cpu_to_be64 ((u64 )skb); + +set_wr_txq (req_skb,CPL_PRIORITY_CONTROL , port_id); +cxgb4_ofld_send (dev->rdev.lldi.ports[0 ], req_skb); +} + +/* +* Handler for CPL_RX_PKT message. Need to handle cpl_rx_pkt +* messages when a filter is being used instead of server to +* redirect a syn packet. When packets hit filter they are redirected +* to the offload queue and driver tries to establish the connection +* using firmware work request. +*/ +static int rx_pkt (struct c4iw_dev *dev,struct sk_buff *skb) +{ +int stid; +unsigned int filter; +struct ethhdr *eh =NULL ; +struct vlan_ethhdr *vlan_eh =NULL ; +struct iphdr *iph; +struct tcphdr *tcph; +struct rss_header *rss = (void *)skb->data; +struct cpl_rx_pkt *cpl = (void *)skb->data; +struct cpl_pass_accept_req *req = (void *)(rss +1 ); +struct l2t_entry *e; +struct dst_entry *dst; +struct rtable *rt; +struct c4iw_ep *lep; +u16 window; +struct port_info *pi; +struct net_device *pdev; +u16 rss_qid; +int step; +u32 tx_chan; +struct neighbour *neigh; + +/* Drop all non-SYN packets */ +if (!(cpl->l2info &cpu_to_be32 (F_RXF_SYN ))) + goto reject; + +/* +* Drop all packets which did not hit the filter. +* Unlikely to happen. +*/ +if (!(rss->filter_hit && rss->filter_tid)) + goto reject; + +/* +* 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 + + dev->rdev.lldi.tids->nstids; + + lep = (struct c4iw_ep *)lookup_stid (dev->rdev.lldi.tids, stid); +if (!lep) { +PDBG ("%s connect request on invalid stid %d\n" , __func__, stid); + goto reject; + } + +if (G_RX_ETHHDR_LEN (ntohl (cpl->l2info)) ==ETH_HLEN ) { + eh = (struct ethhdr *)(req +1 ); + iph = (struct iphdr *)(eh +1 ); + }else { + vlan_eh = (struct vlan_ethhdr *)(req +1 ); + iph = (struct iphdr *)(vlan_eh +1 ); + skb->vlan_tci =ntohs (cpl->vlan); + } + +if (iph->version !=0x4 ) + goto reject; + + tcph = (struct tcphdr *)(iph +1 ); +skb_set_network_header (skb, (void *)iph - (void *)rss); +skb_set_transport_header (skb, (void *)tcph - (void *)rss); +skb_get (skb); + +PDBG ("%s lip 0x%x lport %u pip 0x%x pport %u tos %d\n" , __func__, +ntohl (iph->daddr),ntohs (tcph->dest),ntohl (iph->saddr), +ntohs (tcph->source), iph->tos); + + rt =find_route (dev, iph->daddr, iph->saddr, tcph->dest, tcph->source, + iph->tos); +if (!rt) { +pr_err ("%s - failed to find dst entry!\n" , + __func__); + goto reject; + } + dst = &rt->dst; + neigh =dst_neigh_lookup_skb (dst, skb); + +if (neigh->dev->flags &IFF_LOOPBACK ) { + pdev =ip_dev_find (&init_net, iph->daddr); + e =cxgb4_l2t_get (dev->rdev.lldi.l2t, neigh, + pdev,0 ); + pi = (struct port_info *)netdev_priv (pdev); + tx_chan =cxgb4_port_chan (pdev); +dev_put (pdev); + }else { + e =cxgb4_l2t_get (dev->rdev.lldi.l2t, neigh, + neigh->dev,0 ); + pi = (struct port_info *)netdev_priv (neigh->dev); + tx_chan =cxgb4_port_chan (neigh->dev); + } +if (!e) { +pr_err ("%s - failed to allocate l2t entry!\n" , + __func__); + goto free_dst; + } + + step = dev->rdev.lldi.nrxq / dev->rdev.lldi.nchan; + rss_qid = dev->rdev.lldi.rxq_ids[pi->port_id * step]; + window =htons (tcph->window); + +/* Calcuate filter portion for LE region. */ + filter =cpu_to_be32 (select_ntuple (dev, dst, e)); + +/* +* Synthesize the cpl_pass_accept_req. We have everything except the +* TID. Once firmware sends a reply with TID we update the TID field +* in cpl and pass it through the regular cpl_pass_accept_req path. +*/ +build_cpl_pass_accept_req (skb, stid, iph->tos); +send_fw_pass_open_req (dev, skb, iph->daddr, tcph->dest, iph->saddr, + tcph->source,ntohl (tcph->seq), filter, window, + rss_qid, pi->port_id); +cxgb4_l2t_release (e); +free_dst: +dst_release (dst); +reject:return 0 ; }
@@ -2647,7 +2976,8 @@ static c4iw_handler_func work_handlers[NUM_CPL_CMDS] = { [CPL_CLOSE_CON_RPL] = close_con_rpl, [CPL_RDMA_TERMINATE] = terminate, [CPL_FW4_ACK] = fw4_ack, - [CPL_FW6_MSG] = async_event + [CPL_FW6_MSG] = deferred_fw6_msg, + [CPL_RX_PKT] = rx_pkt };static void process_timeout (struct c4iw_ep *ep)
@@ -2774,9 +3104,6 @@ static int fw6_msg(struct c4iw_dev *dev, struct sk_buff *skb)struct cpl_fw6_msg *rpl =cplhdr (skb);struct c4iw_wr_wait *wr_waitp;int ret; -u8 opcode; -struct cpl_fw6_msg_ofld_connection_wr_rpl *req; -struct c4iw_ep *ep;PDBG ("%s type %u\n" , __func__, rpl->type);
@@ -2790,23 +3117,8 @@ static int fw6_msg(struct c4iw_dev *dev, struct sk_buff *skb)kfree_skb (skb);break ;case FW6_TYPE_CQE : -sched (dev, skb); -break ;case FW6_TYPE_OFLD_CONNECTION_WR_RPL : - opcode = *(const u8 *)rpl->data; -if (opcode ==FW_OFLD_CONNECTION_WR ) { - req = - (struct cpl_fw6_msg_ofld_connection_wr_rpl *)rpl->data; -if (req->t_state ==TCP_SYN_SENT - && (req->retval ==FW_ENOMEM - || req->retval ==FW_EADDRINUSE )) { - ep = (struct c4iw_ep *) -lookup_atid (dev->rdev.lldi.tids, - req->tid); -c4iw_l2t_send (&dev->rdev, skb, ep->l2t); -return 0 ; - } - } +sched (dev, skb);break ;default : printk(KERN_ERR MOD "%s unexpected fw6 msg type %u\n", __func__,
@@ -2868,7 +3180,8 @@ c4iw_handler_func c4iw_handlers[NUM_CPL_CMDS] = { [CPL_RDMA_TERMINATE] = sched, [CPL_FW4_ACK] = sched, [CPL_SET_TCB_RPL] = set_tcb_rpl, - [CPL_FW6_MSG] = fw6_msg + [CPL_FW6_MSG] = fw6_msg, + [CPL_RX_PKT] = sched };int __init c4iw_cm_init (void )
drivers/infiniband/hw/cxgb4/device.c +79 -6
118 lines not on this page · raw message
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +9 -0
@@ -3326,6 +3326,10 @@ int cxgb4_create_server_filter(const struct net_device *dev, unsigned int stid, adap =netdev2adap (dev); +/* Adjust stid to correct filter index */ + stid -= adap->tids.nstids; + stid += adap->tids.nftids; +/* Check to make sure the filter requested is writable ... */ f = &adap->tids.ftid_tab[stid];
@@ -3374,6 +3378,11 @@ int cxgb4_remove_server_filter(const struct net_device *dev, unsigned int stid,struct adapter *adap; adap =netdev2adap (dev); + +/* Adjust stid to correct filter index */ + stid -= adap->tids.nstids; + stid += adap->tids.nftids; + f = &adap->tids.ftid_tab[stid];/* Unlock the filter */ f->locked =0 ;
drivers/net/ethernet/chelsio/cxgb4/t4_msg.h +46 -0
64 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v3 5/5 RDMA/cxgb4: Fix bug for active and passive LE hash collision path
In reply to Vipul PandyaRetries active opens for INUSE errors.
Logs any active ofld_connect_wr error replies.
Sends ofld_connect_wr on same ctrlq. It needs to go on the same control txq as regular CPL active/passive messages.
Retries on active open replies with EADDRINUSE.
Uses active open fw wr only if active filter region is set.
Adds stat for ofld_connect_wr failures.
This patch also adds debugfs file to show endpoints.
---
V2: Changed commenting style from kernel-doc format('/**') to normal
V3: Resending the whole patch series again with the missing patches in V2
drivers/infiniband/hw/cxgb4/cm.c | 277 ++++++++++++++++------- drivers/infiniband/hw/cxgb4/device.c | 125 ++++++++++ drivers/infiniband/hw/cxgb4/iw_cxgb4.h | 32 +++ drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 1 + drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 19 ++- drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h | 8 +- drivers/net/ethernet/chelsio/cxgb4/t4_regs.h | 2 + 7 files changed, 376 insertions(+), 88 deletions(-)
drivers/infiniband/hw/cxgb4/cm.c +195 -82
@@ -275,6 +275,7 @@ void _c4iw_free_ep(struct kref *kref)cxgb4_remove_tid (ep->com.dev->rdev.lldi.tids,0 , ep->hwtid);dst_release (ep->dst);cxgb4_l2t_release (ep->l2t); +remove_handle (ep->com.dev, &ep->com.dev->hwtid_idr, ep->hwtid); }kfree (ep); }
@@ -550,6 +551,7 @@ static int send_connect(struct c4iw_ep *ep) req->opt0 =cpu_to_be64 (opt0); req->params =cpu_to_be32 (select_ntuple (ep->com.dev, ep->dst, ep->l2t)); req->opt2 =cpu_to_be32 (opt2); +set_bit (ACT_OPEN_REQ , &ep->com.history);return c4iw_l2t_send (&ep->com.dev->rdev, skb, ep->l2t); }
@@ -826,6 +828,7 @@ static int act_establish(struct c4iw_dev *dev, struct sk_buff *skb)/* setup the hwtid for this connection */ ep->hwtid = tid;cxgb4_insert_tid (t, ep, tid); +insert_handle (dev, &dev->hwtid_idr, ep, ep->hwtid); ep->snd_seq =be32_to_cpu (req->snd_isn); ep->rcv_seq =be32_to_cpu (req->rcv_isn);
@@ -833,7 +836,9 @@ static int act_establish(struct c4iw_dev *dev, struct sk_buff *skb)set_emss (ep,ntohs (req->tcp_opt));/* dealloc the atid */ +remove_handle (ep->com.dev, &ep->com.dev->atid_idr, atid);cxgb4_free_atid (t, atid); +set_bit (ACT_ESTAB , &ep->com.history);/* start MPA negotiation */ send_flowc (ep,NULL );
@@ -859,6 +864,7 @@ static void close_complete_upcall(struct c4iw_ep *ep) ep->com.cm_id->rem_ref (ep->com.cm_id); ep->com.cm_id =NULL ; ep->com.qp =NULL ; +set_bit (CLOSE_UPCALL , &ep->com.history); } }
@@ -867,6 +873,7 @@ static int abort_connection(struct c4iw_ep *ep, struct sk_buff *skb, gfp_t gfp)PDBG ("%s ep %p tid %u\n" , __func__, ep, ep->hwtid);close_complete_upcall (ep);state_set (&ep->com,ABORTING ); +set_bit (ABORT_CONN , &ep->com.history);return send_abort (ep, skb, gfp); }
@@ -881,6 +888,7 @@ static void peer_close_upcall(struct c4iw_ep *ep)PDBG ("peer close delivered ep %p cm_id %p tid %u\n" , ep, ep->com.cm_id, ep->hwtid); ep->com.cm_id->event_handler (ep->com.cm_id, &event); +set_bit (DISCONN_UPCALL , &ep->com.history); } }
@@ -899,6 +907,7 @@ static void peer_abort_upcall(struct c4iw_ep *ep) ep->com.cm_id->rem_ref (ep->com.cm_id); ep->com.cm_id =NULL ; ep->com.qp =NULL ; +set_bit (ABORT_UPCALL , &ep->com.history); } }
@@ -931,6 +940,7 @@ static void connect_reply_upcall(struct c4iw_ep *ep, int status)PDBG ("%s ep %p tid %u status %d\n" , __func__, ep, ep->hwtid, status); +set_bit (CONN_RPL_UPCALL , &ep->com.history); ep->com.cm_id->event_handler (ep->com.cm_id, &event);if (status <0 ) {
@@ -971,6 +981,7 @@ static void connect_request_upcall(struct c4iw_ep *ep) ep->parent_ep->com.cm_id, &event); } +set_bit (CONNREQ_UPCALL , &ep->com.history);c4iw_put_ep (&ep->parent_ep->com); ep->parent_ep =NULL ; }
@@ -987,6 +998,7 @@ static void established_upcall(struct c4iw_ep *ep)if (ep->com.cm_id) {PDBG ("%s ep %p tid %u\n" , __func__, ep, ep->hwtid); ep->com.cm_id->event_handler (ep->com.cm_id, &event); +set_bit (ESTAB_UPCALL , &ep->com.history); } }
@@ -1372,6 +1384,7 @@ static int rx_data(struct c4iw_dev *dev, struct sk_buff *skb)unsigned int dlen =ntohs (hdr->len);unsigned int tid =GET_TID (hdr);struct tid_info *t = dev->rdev.lldi.tids; +__u8 status = hdr->status; ep =lookup_tid (t, tid);PDBG ("%s ep %p tid %u dlen %u\n" , __func__, ep, ep->hwtid, dlen);
@@ -1394,9 +1407,9 @@ static int rx_data(struct c4iw_dev *dev, struct sk_buff *skb)case MPA_REP_SENT :break ;default : - printk(KERN_ERR MOD "%s Unexpected streaming data." -" ep %p state %d tid %u\n" , - __func__, ep, state_read(&ep->com), ep->hwtid); +pr_err ("%s Unexpected streaming data." \ +" ep %p state %d tid %u status %d\n" , + __func__, ep,state_read (&ep->com), ep->hwtid, status);/* * The ep will timeout and inform the ULP of the failure.
@@ -1463,6 +1476,7 @@ static void send_fw_act_open_req(struct c4iw_ep *ep, unsigned int atid) req->tcb.cplrxdataack_cplpassacceptrpl =htons (F_FW_OFLD_CONNECTION_WR_CPLRXDATAACK ); req->tcb.tx_max = jiffies; + req->tcb.rcv_adv =htons (1 );cxgb4_best_mtu (ep->com.dev->rdev.lldi.mtus, ep->mtu, &mtu_idx); wscale =compute_wscale (rcv_win); req->tcb.opt0 = TCAM_BYPASS(1) |
@@ -1490,7 +1504,8 @@ static void send_fw_act_open_req(struct c4iw_ep *ep, unsigned int atid) req->tcb.opt2 |=WND_SCALE_EN (1 ); req->tcb.opt0 =cpu_to_be64 (req->tcb.opt0); req->tcb.opt2 =cpu_to_be32 (req->tcb.opt2); -set_wr_txq (skb,CPL_PRIORITY_CONTROL ,0 ); +set_wr_txq (skb,CPL_PRIORITY_CONTROL , ep->ctrlq_idx); +set_bit (ACT_OFLD_CONN , &ep->com.history);c4iw_l2t_send (&ep->com.dev->rdev, skb, ep->l2t); }
@@ -1503,6 +1518,111 @@ static inline int act_open_has_tid(int status) status !=CPL_ERR_ARP_MISS ; } +#define ACT_OPEN_RETRY_COUNT 2 + +static int c4iw_reconnect (struct c4iw_ep *ep) +{ +int err =0 ; +struct rtable *rt; +struct port_info *pi; +struct net_device *pdev; +int step; +struct neighbour *neigh; + +PDBG ("%s qp %p cm_id %p\n" , __func__, ep->com.qp, ep->com.cm_id); +init_timer (&ep->timer); + +/* +* Allocate an active TID to initiate a TCP connection. +*/ + ep->atid =cxgb4_alloc_atid (ep->com.dev->rdev.lldi.tids, ep); +if (ep->atid ==-1 ) { +pr_err ("%s - cannot alloc atid.\n" , __func__); + err = -ENOMEM ; + goto fail2; + } +insert_handle (ep->com.dev, &ep->com.dev->atid_idr, ep, ep->atid); + +/* find a route */ + rt =find_route (ep->com.dev, + ep->com.cm_id->local_addr.sin_addr.s_addr, + ep->com.cm_id->remote_addr.sin_addr.s_addr, + ep->com.cm_id->local_addr.sin_port, + ep->com.cm_id->remote_addr.sin_port,0 ); +if (!rt) { +pr_err ("%s - cannot find route.\n" , __func__); + err = -EHOSTUNREACH ; + goto fail3; + } + ep->dst = &rt->dst; + + neigh =dst_neigh_lookup (ep->dst, + &ep->com.cm_id->remote_addr.sin_addr.s_addr); +/* get a l2t entry */ +if (neigh->dev->flags &IFF_LOOPBACK ) { +PDBG ("%s LOOPBACK\n" , __func__); + pdev =ip_dev_find (&init_net, + ep->com.cm_id->remote_addr.sin_addr.s_addr); + ep->l2t =cxgb4_l2t_get (ep->com.dev->rdev.lldi.l2t, + neigh, pdev,0 ); + pi = (struct port_info *)netdev_priv (pdev); + ep->mtu = pdev->mtu; + ep->tx_chan =cxgb4_port_chan (pdev); + ep->smac_idx = (cxgb4_port_viid (pdev) &0x7F ) <<1 ; +dev_put (pdev); + }else { + ep->l2t =cxgb4_l2t_get (ep->com.dev->rdev.lldi.l2t, + neigh, neigh->dev,0 ); + pi = (struct port_info *)netdev_priv (neigh->dev); + ep->mtu =dst_mtu (ep->dst); + ep->tx_chan =cxgb4_port_chan (neigh->dev); + ep->smac_idx = (cxgb4_port_viid (neigh->dev) & +0x7F ) <<1 ; + } + + step = ep->com.dev->rdev.lldi.ntxq / ep->com.dev->rdev.lldi.nchan; + ep->txq_idx = pi->port_id * step; + ep->ctrlq_idx = pi->port_id; + step = ep->com.dev->rdev.lldi.nrxq / ep->com.dev->rdev.lldi.nchan; + ep->rss_qid = ep->com.dev->rdev.lldi.rxq_ids[pi->port_id * step]; + +if (!ep->l2t) { +pr_err ("%s - cannot alloc l2e.\n" , __func__); + err = -ENOMEM ; + goto fail4; + } + +PDBG ("%s txq_idx %u tx_chan %u smac_idx %u rss_qid %u l2t_idx %u\n" , + __func__, ep->txq_idx, ep->tx_chan, ep->smac_idx, ep->rss_qid, + ep->l2t->idx); + +state_set (&ep->com,CONNECTING ); + ep->tos =0 ; + +/* send connect request to rnic */ + err =send_connect (ep); +if (!err) + goto out; + +cxgb4_l2t_release (ep->l2t); +fail4: +dst_release (ep->dst); +fail3: +remove_handle (ep->com.dev, &ep->com.dev->atid_idr, ep->atid); +cxgb4_free_atid (ep->com.dev->rdev.lldi.tids, ep->atid); +fail2: +/* +* remember to send notification to upper layer. +* We are in here so the upper layer is not aware that this is +* re-connect attempt and so, upper layer is still waiting for +* response of 1st connect request. +*/ +connect_reply_upcall (ep, -ECONNRESET ); +c4iw_put_ep (&ep->com); +out: +return err; +} +static int act_open_rpl (struct c4iw_dev *dev,struct sk_buff *skb) {struct c4iw_ep *ep;
@@ -1523,6 +1643,8 @@ static int act_open_rpl(struct c4iw_dev *dev, struct sk_buff *skb)return 0 ; } +set_bit (ACT_OPEN_RPL , &ep->com.history); +/* * Log interesting failures. */
@@ -1531,12 +1653,27 @@ static int act_open_rpl(struct c4iw_dev *dev, struct sk_buff *skb)case CPL_ERR_CONN_TIMEDOUT :break ;case CPL_ERR_TCAM_FULL : -mutex_lock (&dev->rdev.stats.lock); - dev->rdev.stats.tcam_full++; -mutex_unlock (&dev->rdev.stats.lock); -send_fw_act_open_req (ep, -GET_TID_TID (GET_AOPEN_ATID (ntohl (rpl->atid_status)))); -return 0 ; +if (dev->rdev.lldi.enable_fw_ofld_conn) { +mutex_lock (&dev->rdev.stats.lock); + dev->rdev.stats.tcam_full++; +mutex_unlock (&dev->rdev.stats.lock); +send_fw_act_open_req (ep, +GET_TID_TID (GET_AOPEN_ATID ( +ntohl (rpl->atid_status)))); +return 0 ; + } +break ; +case CPL_ERR_CONN_EXIST : +if (ep->retry_count++ <ACT_OPEN_RETRY_COUNT ) { +set_bit (ACT_RETRY_INUSE , &ep->com.history); +remove_handle (ep->com.dev, &ep->com.dev->atid_idr, + atid); +cxgb4_free_atid (t, atid); +dst_release (ep->dst); +cxgb4_l2t_release (ep->l2t); +c4iw_reconnect (ep); +return 0 ; + }break ;default : printk(KERN_INFO MOD "Active open failure - "
@@ -1555,6 +1692,7 @@ static int act_open_rpl(struct c4iw_dev *dev, struct sk_buff *skb)if (status &&act_open_has_tid (status))cxgb4_remove_tid (ep->com.dev->rdev.lldi.tids,0 ,GET_TID (rpl)); +remove_handle (ep->com.dev, &ep->com.dev->atid_idr, atid);cxgb4_free_atid (t, atid);dst_release (ep->dst);cxgb4_l2t_release (ep->l2t);
@@ -1775,7 +1913,7 @@ out:static int pass_accept_req (struct c4iw_dev *dev,struct sk_buff *skb) { -struct c4iw_ep *child_ep, *parent_ep; +struct c4iw_ep *child_ep =NULL , *parent_ep;struct cpl_pass_accept_req *req =cplhdr (skb);unsigned int stid =GET_POPEN_TID (ntohl (req->tos_stid));struct tid_info *t = dev->rdev.lldi.tids;
@@ -1856,6 +1994,7 @@ static int pass_accept_req(struct c4iw_dev *dev, struct sk_buff *skb)init_timer (&child_ep->timer);cxgb4_insert_tid (t, child_ep, hwtid);accept_cr (child_ep, peer_ip, skb, req); +set_bit (PASS_ACCEPT_REQ , &child_ep->com.history); goto out; reject:reject_cr (dev, hwtid, peer_ip, skb);
@@ -1879,11 +2018,13 @@ static int pass_establish(struct c4iw_dev *dev, struct sk_buff *skb) ntohs(req->tcp_opt));set_emss (ep,ntohs (req->tcp_opt)); +insert_handle (dev, &dev->hwtid_idr, ep, ep->hwtid);dst_confirm (ep->dst);state_set (&ep->com,MPA_REQ_WAIT );start_ep_timer (ep);send_flowc (ep, skb); +set_bit (PASS_ESTAB , &ep->com.history);return 0 ; }
@@ -1903,6 +2044,7 @@ static int peer_close(struct c4iw_dev *dev, struct sk_buff *skb)PDBG ("%s ep %p tid %u\n" , __func__, ep, ep->hwtid);dst_confirm (ep->dst); +set_bit (PEER_CLOSE , &ep->com.history);mutex_lock (&ep->com.mutex);switch (ep->com.state) {case MPA_REQ_WAIT :
@@ -1982,74 +2124,6 @@ static int is_neg_adv_abort(unsigned int status) status ==CPL_ERR_PERSIST_NEG_ADVICE ; } -static int c4iw_reconnect (struct c4iw_ep *ep) -{ -struct rtable *rt; -int err =0 ; - -PDBG ("%s qp %p cm_id %p\n" , __func__, ep->com.qp, ep->com.cm_id); -init_timer (&ep->timer); - -/* -* Allocate an active TID to initiate a TCP connection. -*/ - ep->atid =cxgb4_alloc_atid (ep->com.dev->rdev.lldi.tids, ep); -if (ep->atid ==-1 ) { - printk(KERN_ERR MOD "%s - cannot alloc atid.\n", __func__); - err = -ENOMEM ; - goto fail2; - } - -/* find a route */ - rt =find_route (ep->com.dev, - ep->com.cm_id->local_addr.sin_addr.s_addr, - ep->com.cm_id->remote_addr.sin_addr.s_addr, - ep->com.cm_id->local_addr.sin_port, - ep->com.cm_id->remote_addr.sin_port,0 ); -if (!rt) { - printk(KERN_ERR MOD "%s - cannot find route.\n", __func__); - err = -EHOSTUNREACH ; - goto fail3; - } - ep->dst = &rt->dst; - - err =import_ep (ep, ep->com.cm_id->remote_addr.sin_addr.s_addr, - ep->dst, ep->com.dev, false); -if (err) { - printk(KERN_ERR MOD "%s - cannot alloc l2e.\n", __func__); - goto fail4; - } - -PDBG ("%s txq_idx %u tx_chan %u smac_idx %u rss_qid %u l2t_idx %u\n" , - __func__, ep->txq_idx, ep->tx_chan, ep->smac_idx, ep->rss_qid, - ep->l2t->idx); - -state_set (&ep->com,CONNECTING ); - ep->tos =0 ; - -/* send connect request to rnic */ - err =send_connect (ep); -if (!err) - goto out; - -cxgb4_l2t_release (ep->l2t); -fail4: -dst_release (ep->dst); -fail3: -cxgb4_free_atid (ep->com.dev->rdev.lldi.tids, ep->atid); -fail2: -/* -* remember to send notification to upper layer. -* We are in here so the upper layer is not aware that this is -* re-connect attempt and so, upper layer is still waiting for -* response of 1st connect request. -*/ -connect_reply_upcall (ep, -ECONNRESET ); -c4iw_put_ep (&ep->com); -out: -return err; -} -static int peer_abort (struct c4iw_dev *dev,struct sk_buff *skb) {struct cpl_abort_req_rss *req =cplhdr (skb);
@@ -2070,6 +2144,7 @@ static int peer_abort(struct c4iw_dev *dev, struct sk_buff *skb) }PDBG ("%s ep %p tid %u state %u\n" , __func__, ep, ep->hwtid, ep->com.state); +set_bit (PEER_ABORT , &ep->com.history);/* * Wake up any threads in rdma_init() or rdma_fini().
@@ -2284,6 +2359,7 @@ int c4iw_reject_cr(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)c4iw_put_ep (&ep->com);return -ECONNRESET ; } +set_bit (ULP_REJECT , &ep->com.history);BUG_ON (state_read (&ep->com) !=MPA_REQ_RCVD );if (mpa_rev ==0 )abort_connection (ep,NULL ,GFP_KERNEL );
@@ -2313,6 +2389,7 @@ int c4iw_accept_cr(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)BUG_ON (state_read (&ep->com) !=MPA_REQ_RCVD );BUG_ON (!qp); +set_bit (ULP_ACCEPT , &ep->com.history);if ((conn_param->ord > c4iw_max_read_depth) || (conn_param->ird > c4iw_max_read_depth)) {abort_connection (ep,NULL ,GFP_KERNEL );
@@ -2436,6 +2513,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) err = -ENOMEM ; goto fail2; } +insert_handle (dev, &dev->atid_idr, ep, ep->atid); PDBG("%s saddr 0x%x sport 0x%x raddr 0x%x rport 0x%x\n", __func__, ntohl(cm_id->local_addr.sin_addr.s_addr),
@@ -2481,6 +2559,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) fail4:dst_release (ep->dst); fail3: +remove_handle (ep->com.dev, &ep->com.dev->atid_idr, ep->atid);cxgb4_free_atid (ep->com.dev->rdev.lldi.tids, ep->atid); fail2: cm_id->rem_ref (cm_id);
@@ -2523,6 +2602,7 @@ int c4iw_create_listen(struct iw_cm_id *cm_id, int backlog) err = -ENOMEM ; goto fail2; } +insert_handle (dev, &dev->stid_idr, ep, ep->stid);state_set (&ep->com,LISTEN );if (dev->rdev.lldi.enable_fw_ofld_conn) { do {
@@ -2530,7 +2610,10 @@ int c4iw_create_listen(struct iw_cm_id *cm_id, int backlog) ep->com.dev->rdev.lldi.ports[0 ], ep->stid, ep->com.local_addr.sin_addr.s_addr, ep->com.local_addr.sin_port, - ep->com.dev->rdev.lldi.rxq_ids[0]); +0 , + ep->com.dev->rdev.lldi.rxq_ids[0 ], +0 , + 0);if (err == -EBUSY ) {set_current_state (TASK_UNINTERRUPTIBLE );schedule_timeout (usecs_to_jiffies (100 ));
@@ -2541,6 +2624,7 @@ int c4iw_create_listen(struct iw_cm_id *cm_id, int backlog) err =cxgb4_create_server (ep->com.dev->rdev.lldi.ports[0 ], ep->stid, ep->com.local_addr.sin_addr.s_addr, ep->com.local_addr.sin_port, +0 , ep->com.dev->rdev.lldi.rxq_ids[0 ]);if (!err) err = c4iw_wait_for_reply(&ep->com.dev->rdev,
@@ -2586,6 +2670,7 @@ int c4iw_destroy_listen(struct iw_cm_id *cm_id) err =c4iw_wait_for_reply (&ep->com.dev->rdev, &ep->com.wr_wait,0 ,0 , __func__); } +remove_handle (ep->com.dev, &ep->com.dev->stid_idr, ep->stid);cxgb4_free_stid (ep->com.dev->rdev.lldi.tids, ep->stid,PF_INET ); done: cm_id->rem_ref (cm_id);
@@ -2649,10 +2734,13 @@ int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp)if (close) {if (abrupt) { +set_bit (EP_DISC_ABORT , &ep->com.history);close_complete_upcall (ep); ret =send_abort (ep,NULL , gfp); - }else + }else { +set_bit (EP_DISC_CLOSE , &ep->com.history); ret =send_halfclose (ep, gfp); + }if (ret) fatal =1 ; }
@@ -2666,6 +2754,7 @@ static void active_ofld_conn_reply(struct c4iw_dev *dev, struct sk_buff *skb, struct cpl_fw6_msg_ofld_connection_wr_rpl *req) {struct c4iw_ep *ep; +int atid =be32_to_cpu (req->tid); ep = (struct c4iw_ep *)lookup_atid (dev->rdev.lldi.tids, req->tid);if (!ep)
@@ -2673,15 +2762,35 @@ static void active_ofld_conn_reply(struct c4iw_dev *dev, struct sk_buff *skb,switch (req->retval) {case FW_ENOMEM : +set_bit (ACT_RETRY_NOMEM , &ep->com.history); +if (ep->retry_count++ <ACT_OPEN_RETRY_COUNT ) { +send_fw_act_open_req (ep, atid); +return ; + }case FW_EADDRINUSE : -PDBG ("%s ofld conn wr ret %d\n" , __func__, req->retval); +set_bit (ACT_RETRY_INUSE , &ep->com.history); +if (ep->retry_count++ <ACT_OPEN_RETRY_COUNT ) { +send_fw_act_open_req (ep, atid); +return ; + }break ;default :pr_info ("%s unexpected ofld conn wr retval %d\n" , __func__, req->retval);break ; } +pr_err ("active ofld_connect_wr failure %d atid %d\n" , + req->retval, atid); +mutex_lock (&dev->rdev.stats.lock); + dev->rdev.stats.act_ofld_conn_fails++; +mutex_unlock (&dev->rdev.stats.lock);connect_reply_upcall (ep,status2errno (req->retval)); +state_set (&ep->com,DEAD ); +remove_handle (dev, &dev->atid_idr, atid); +cxgb4_free_atid (dev->rdev.lldi.tids, atid); +dst_release (ep->dst); +cxgb4_l2t_release (ep->l2t); +c4iw_put_ep (&ep->com); } static void passive_ofld_conn_reply(struct c4iw_dev *dev, struct sk_buff *skb,
@@ -2695,6 +2804,9 @@ static void passive_ofld_conn_reply(struct c4iw_dev *dev, struct sk_buff *skb,BUG_ON (!rpl_skb);if (req->retval) {PDBG ("%s passive open failure %d\n" , __func__, req->retval); +mutex_lock (&dev->rdev.stats.lock); + dev->rdev.stats.pas_ofld_conn_fails++; +mutex_unlock (&dev->rdev.stats.lock);kfree_skb (rpl_skb); }else { cpl = (struct cpl_pass_accept_req *)cplhdr (rpl_skb);
@@ -2988,6 +3100,7 @@ static void process_timeout(struct c4iw_ep *ep)mutex_lock (&ep->com.mutex);PDBG ("%s ep %p tid %u state %d\n" , __func__, ep, ep->hwtid, ep->com.state); +set_bit (TIMEDOUT , &ep->com.history);switch (ep->com.state) {case MPA_REQ_SENT :__state_set (&ep->com,ABORTING );
drivers/infiniband/hw/cxgb4/device.c +125 -0
161 lines not on this page · raw message
drivers/infiniband/hw/cxgb4/iw_cxgb4.h +32 -0
@@ -131,6 +131,8 @@ struct c4iw_stats {u64 db_drop;u64 db_state_transitions;u64 tcam_full; +u64 act_ofld_conn_fails; +u64 pas_ofld_conn_fails; };struct c4iw_rdev {
@@ -224,6 +226,9 @@ struct c4iw_dev {struct dentry *debugfs_root;enum db_state db_state;int qpcnt; +struct idr hwtid_idr; +struct idr atid_idr; +struct idr stid_idr; };static inline struct c4iw_dev *to_c4iw_dev (struct ib_device *ibdev)
@@ -713,6 +718,31 @@ enum c4iw_ep_flags { CLOSE_SENT = 3, }; +enum c4iw_ep_history { +ACT_OPEN_REQ =0 , +ACT_OFLD_CONN =1 , +ACT_OPEN_RPL =2 , +ACT_ESTAB =3 , +PASS_ACCEPT_REQ =4 , +PASS_ESTAB =5 , +ABORT_UPCALL =6 , +ESTAB_UPCALL =7 , +CLOSE_UPCALL =8 , +ULP_ACCEPT =9 , +ULP_REJECT =10 , +TIMEDOUT =11 , +PEER_ABORT =12 , +PEER_CLOSE =13 , +CONNREQ_UPCALL =14 , +ABORT_CONN =15 , +DISCONN_UPCALL =16 , +EP_DISC_CLOSE =17 , +EP_DISC_ABORT =18 , +CONN_RPL_UPCALL =19 , +ACT_RETRY_NOMEM =20 , +ACT_RETRY_INUSE =21 +}; +struct c4iw_ep_common {struct iw_cm_id *cm_id;struct c4iw_qp *qp;
@@ -724,6 +754,7 @@ struct c4iw_ep_common {struct sockaddr_in remote_addr;struct c4iw_wr_wait wr_wait;unsigned long flags; +unsigned long history; };struct c4iw_listen_ep {
@@ -761,6 +792,7 @@ struct c4iw_ep {u8 tos;u8 retry_with_mpa_v1;u8 tried_with_mpa_v1; +unsigned int retry_count; };static inline struct c4iw_ep *to_ep (struct iw_cm_id *cm_id)
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +1 -0
@@ -530,6 +530,7 @@ struct adapter {struct net_device *port[MAX_NPORTS ];u8 chan_map[NCHAN ];/* channel -> port map */ +u32 filter_mode;unsigned int l2t_start;unsigned int l2t_end;struct l2t_data *l2t;
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +15 -4
@@ -2678,7 +2678,8 @@ static int tid_init(struct tid_info *t)* Returns <0 on error and one of the %NET_XMIT_* values on success. */ int cxgb4_create_server (const struct net_device *dev,unsigned int stid, -__be32 sip,__be16 sport,unsigned int queue) +__be32 sip,__be16 sport,__be16 vlan, +unsigned int queue) {unsigned int chan;struct sk_buff *skb;
@@ -3051,7 +3052,7 @@ static void uld_attach(struct adapter *adap, unsigned int uld) lli.ucq_density =1 <<QUEUESPERPAGEPF0_GET (t4_read_reg (adap,SGE_INGRESS_QUEUES_PER_PAGE_PF ) >> (adap->fn *4 )); - lli.filt_mode = tp_vlan_pri_map; + lli.filt_mode = adap->filter_mode;/* MODQ_REQ_MAP sets queues 0-3 to chan 0-3 */ for (i =0 ; i <NCHAN ; i++) lli.tx_modq[i] = i;
@@ -3316,7 +3317,8 @@ static int delete_filter(struct adapter *adapter, unsigned int fidx) }int cxgb4_create_server_filter (const struct net_device *dev,unsigned int stid, -__be32 sip,__be16 sport,unsigned int queue) +__be32 sip,__be16 sport,__be16 vlan, +unsigned int queue,unsigned char port,unsigned char mask) {int ret;struct filter_entry *f;
@@ -3348,11 +3350,16 @@ int cxgb4_create_server_filter(const struct net_device *dev, unsigned int stid, f->fs.val.lport =cpu_to_be16 (sport); f->fs.mask.lport = ~0 ; val = (u8 *)&sip; -if ((val[0 ] | val[1 ] | val[2 ] | val[3 ]) !=0 ) +if ((val[0 ] | val[1 ] | val[2 ] | val[3 ]) !=0 ) {for (i =0 ; i <4 ; i++) { f->fs.val.lip[i] = val[i]; f->fs.mask.lip[i] = ~0 ; } +if (adap->filter_mode &F_PORT ) { + f->fs.val.iport = port; + f->fs.mask.iport = mask; + } + } f->fs.dirsteer =1 ; f->fs.iq = queue;
@@ -4459,6 +4466,10 @@ static int adap_init0(struct adapter *adap)for (j =0 ; j <NCHAN ; j++) adap->params.tp.tx_modq[j] = j; +t4_read_indirect (adap,TP_PIO_ADDR ,TP_PIO_DATA , + &adap->filter_mode,1 , +TP_VLAN_PRI_MAP ); + adap->flags |=FW_OK ;return 0 ;
drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h +6 -2
@@ -38,6 +38,7 @@#include <linux/cache.h> #include <linux/spinlock.h> #include <linux/skbuff.h> +#include <linux/inetdevice.h> #include <linux/atomic.h> /* CPL message priority levels */
@@ -151,9 +152,12 @@ void cxgb4_remove_tid(struct tid_info *t, unsigned int qid, unsigned int tid);struct in6_addr ;int cxgb4_create_server (const struct net_device *dev,unsigned int stid, -__be32 sip,__be16 sport,unsigned int queue); +__be32 sip,__be16 sport,__be16 vlan, +unsigned int queue);int cxgb4_create_server_filter (const struct net_device *dev,unsigned int stid, -__be32 sip,__be16 sport,unsigned int queue); +__be32 sip,__be16 sport,__be16 vlan, +unsigned int queue, +unsigned char port,unsigned char mask);int cxgb4_remove_server_filter (const struct net_device *dev,unsigned int stid,unsigned int queue,bool ipv6);static inline void set_wr_txq (struct sk_buff *skb,int prio,int queue)
drivers/net/ethernet/chelsio/cxgb4/t4_regs.h +2 -0
@@ -1066,5 +1066,7 @@#define A_TP_TX_SCHED_PCMD 0x25#define S_PORT 1 +#define V_PORT (x) ((x) << S_PORT) +#define F_PORT V_PORT(1U)#endif /* __T4_REGS_H */
Signature · 1 line
1.7.1
Re: [PATCH V3 1/5] cxgb4: Add T4 filter support
In reply to a message not in the archiveFrom: Vipul Pandya <[email protected]>
Date: Mon, 3 Dec 2012 16:52:57 +0530
Quoted 4 lines
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +4
-0+/* +* If the new or old filter have loopback rewriteing rules then we'll +* need to free any existing Layer Two Table (L2T) entries of the old +* filter rule. The firmware will handle freeing up any Source MAC
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c static int link_start(struct net_device *dev) · line 557
Quoted 10 lines
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +10
-0+* Table (SMT) entries used for rewriting Source MAC Addresses in +* loopback rules. +*/ +if (f->l2t) +cxgb4_l2t_release (f->l2t); + +/* The zeroing of the filter rule below clears the filter valid, +* pending, locked flags, l2t pointer, etc. so it's all we need for +* this operation. +*/
My greatest amusement is achieved when someone gets a code formatting rule both correct and wrong in the same patch, as you have done here.
Format comments in the networking:
/* Like * this. */ /* * Never, * like this. */
Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH V3 1/5] cxgb4: Add T4 filter support
Quoted 32 lines · David Miller
From: Vipul Pandya <[email protected]>
Date: Mon, 3 Dec 2012 16:52:57 +0530Quoted 4 lines
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +4
-0+/* +* If the new or old filter have loopback rewriteing rules then we'll +* need to free any existing Layer Two Table (L2T) entries of the old +* filter rule. The firmware will handle freeing up any Source MAC drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c static int link_start(struct net_device *dev) · line 557
Quoted 10 lines
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +10
-0+* Table (SMT) entries used for rewriting Source MAC Addresses in +* loopback rules. +*/ +if (f->l2t) +cxgb4_l2t_release (f->l2t); + +/* The zeroing of the filter rule below clears the filter valid, +* pending, locked flags, l2t pointer, etc. so it's all we need for +* this operation. +*/ My greatest amusement is achieved when someone gets a code formatting rule both correct and wrong in the same patch, as you have done here.
Format comments in the networking:
/* Like * this. */ /* * Never, * like this. */
Quoted 2 lines
Thanks.
I have submitted the series again making above changes. Thanks for pointing out the same. I wonder how checkpatch.pl did not complain or gave a warning for the incorrect commenting style. I corrected only those comments for which checkpatch.pl gave me a warning. So, I think there are some checks missing in checkpatch.pl script.
Thanks,
Vipul