diff options
Diffstat (limited to 'include/rdma')
| -rw-r--r-- | include/rdma/ib_addr.h | 69 | ||||
| -rw-r--r-- | include/rdma/ib_pack.h | 1 | ||||
| -rw-r--r-- | include/rdma/ib_sa.h | 3 | ||||
| -rw-r--r-- | include/rdma/ib_umem.h | 11 | ||||
| -rw-r--r-- | include/rdma/ib_verbs.h | 277 | ||||
| -rw-r--r-- | include/rdma/iw_portmap.h | 199 | ||||
| -rw-r--r-- | include/rdma/rdma_netlink.h | 23 | 
7 files changed, 533 insertions, 50 deletions
diff --git a/include/rdma/ib_addr.h b/include/rdma/ib_addr.h index f3ac0f2c4c6..ce55906b54a 100644 --- a/include/rdma/ib_addr.h +++ b/include/rdma/ib_addr.h @@ -38,10 +38,15 @@  #include <linux/in6.h>  #include <linux/if_arp.h>  #include <linux/netdevice.h> +#include <linux/inetdevice.h>  #include <linux/socket.h>  #include <linux/if_vlan.h> +#include <net/ipv6.h> +#include <net/if_inet6.h> +#include <net/ip.h>  #include <rdma/ib_verbs.h>  #include <rdma/ib_pack.h> +#include <net/ipv6.h>  struct rdma_addr_client {  	atomic_t refcount; @@ -72,7 +77,8 @@ struct rdma_dev_addr {   * rdma_translate_ip - Translate a local IP address to an RDMA hardware   *   address.   */ -int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr); +int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr, +		      u16 *vlan_id);  /**   * rdma_resolve_ip - Resolve source and destination IP addresses to @@ -104,6 +110,10 @@ int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev,  int rdma_addr_size(struct sockaddr *addr); +int rdma_addr_find_smac_by_sgid(union ib_gid *sgid, u8 *smac, u16 *vlan_id); +int rdma_addr_find_dmac_by_grh(union ib_gid *sgid, union ib_gid *dgid, u8 *smac, +			       u16 *vlan_id); +  static inline u16 ib_addr_get_pkey(struct rdma_dev_addr *dev_addr)  {  	return ((u16)dev_addr->broadcast[8] << 8) | (u16)dev_addr->broadcast[9]; @@ -126,41 +136,60 @@ static inline int rdma_addr_gid_offset(struct rdma_dev_addr *dev_addr)  	return dev_addr->dev_type == ARPHRD_INFINIBAND ? 4 : 0;  } -static inline void iboe_mac_vlan_to_ll(union ib_gid *gid, u8 *mac, u16 vid) +static inline u16 rdma_vlan_dev_vlan_id(const struct net_device *dev)  { -	memset(gid->raw, 0, 16); -	*((__be32 *) gid->raw) = cpu_to_be32(0xfe800000); -	if (vid < 0x1000) { -		gid->raw[12] = vid & 0xff; -		gid->raw[11] = vid >> 8; -	} else { -		gid->raw[12] = 0xfe; -		gid->raw[11] = 0xff; +	return dev->priv_flags & IFF_802_1Q_VLAN ? +		vlan_dev_vlan_id(dev) : 0xffff; +} + +static inline int rdma_ip2gid(struct sockaddr *addr, union ib_gid *gid) +{ +	switch (addr->sa_family) { +	case AF_INET: +		ipv6_addr_set_v4mapped(((struct sockaddr_in *) +					addr)->sin_addr.s_addr, +				       (struct in6_addr *)gid); +		break; +	case AF_INET6: +		memcpy(gid->raw, &((struct sockaddr_in6 *)addr)->sin6_addr, 16); +		break; +	default: +		return -EINVAL;  	} -	memcpy(gid->raw + 13, mac + 3, 3); -	memcpy(gid->raw + 8, mac, 3); -	gid->raw[8] ^= 2; +	return 0;  } -static inline u16 rdma_vlan_dev_vlan_id(const struct net_device *dev) +/* Important - sockaddr should be a union of sockaddr_in and sockaddr_in6 */ +static inline int rdma_gid2ip(struct sockaddr *out, union ib_gid *gid)  { -	return dev->priv_flags & IFF_802_1Q_VLAN ? -		vlan_dev_vlan_id(dev) : 0xffff; +	if (ipv6_addr_v4mapped((struct in6_addr *)gid)) { +		struct sockaddr_in *out_in = (struct sockaddr_in *)out; +		memset(out_in, 0, sizeof(*out_in)); +		out_in->sin_family = AF_INET; +		memcpy(&out_in->sin_addr.s_addr, gid->raw + 12, 4); +	} else { +		struct sockaddr_in6 *out_in = (struct sockaddr_in6 *)out; +		memset(out_in, 0, sizeof(*out_in)); +		out_in->sin6_family = AF_INET6; +		memcpy(&out_in->sin6_addr.s6_addr, gid->raw, 16); +	} +	return 0;  }  static inline void iboe_addr_get_sgid(struct rdma_dev_addr *dev_addr,  				      union ib_gid *gid)  {  	struct net_device *dev; -	u16 vid = 0xffff; +	struct in_device *ip4;  	dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if);  	if (dev) { -		vid = rdma_vlan_dev_vlan_id(dev); +		ip4 = (struct in_device *)dev->ip_ptr; +		if (ip4 && ip4->ifa_list && ip4->ifa_list->ifa_address) +			ipv6_addr_set_v4mapped(ip4->ifa_list->ifa_address, +					       (struct in6_addr *)gid);  		dev_put(dev);  	} - -	iboe_mac_vlan_to_ll(gid, dev_addr->src_dev_addr, vid);  }  static inline void rdma_addr_get_sgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid) diff --git a/include/rdma/ib_pack.h b/include/rdma/ib_pack.h index b37fe3b10a9..b1f7592e02e 100644 --- a/include/rdma/ib_pack.h +++ b/include/rdma/ib_pack.h @@ -34,6 +34,7 @@  #define IB_PACK_H  #include <rdma/ib_verbs.h> +#include <uapi/linux/if_ether.h>  enum {  	IB_LRH_BYTES  = 8, diff --git a/include/rdma/ib_sa.h b/include/rdma/ib_sa.h index 125f8714301..7e071a6abb3 100644 --- a/include/rdma/ib_sa.h +++ b/include/rdma/ib_sa.h @@ -154,6 +154,9 @@ struct ib_sa_path_rec {  	u8           packet_life_time_selector;  	u8           packet_life_time;  	u8           preference; +	u8           smac[ETH_ALEN]; +	u8           dmac[ETH_ALEN]; +	u16	     vlan_id;  };  #define IB_SA_MCMEMBER_REC_MGID				IB_SA_COMP_MASK( 0) diff --git a/include/rdma/ib_umem.h b/include/rdma/ib_umem.h index 9ee0d2e51b1..1ea0b65c4cf 100644 --- a/include/rdma/ib_umem.h +++ b/include/rdma/ib_umem.h @@ -46,17 +46,12 @@ struct ib_umem {  	int			page_size;  	int                     writable;  	int                     hugetlb; -	struct list_head	chunk_list;  	struct work_struct	work;  	struct mm_struct       *mm;  	unsigned long		diff; -}; - -struct ib_umem_chunk { -	struct list_head	list; -	int                     nents; -	int                     nmap; -	struct scatterlist      page_list[0]; +	struct sg_table sg_head; +	int             nmap; +	int             npages;  };  #ifdef CONFIG_INFINIBAND_USER_MEM diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index e393171e2fa..7ccef342f72 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -48,6 +48,7 @@  #include <linux/rwsem.h>  #include <linux/scatterlist.h>  #include <linux/workqueue.h> +#include <uapi/linux/if_ether.h>  #include <linux/atomic.h>  #include <asm/uaccess.h> @@ -67,16 +68,20 @@ enum rdma_node_type {  	RDMA_NODE_IB_CA 	= 1,  	RDMA_NODE_IB_SWITCH,  	RDMA_NODE_IB_ROUTER, -	RDMA_NODE_RNIC +	RDMA_NODE_RNIC, +	RDMA_NODE_USNIC, +	RDMA_NODE_USNIC_UDP,  };  enum rdma_transport_type {  	RDMA_TRANSPORT_IB, -	RDMA_TRANSPORT_IWARP +	RDMA_TRANSPORT_IWARP, +	RDMA_TRANSPORT_USNIC, +	RDMA_TRANSPORT_USNIC_UDP  }; -enum rdma_transport_type -rdma_node_get_transport(enum rdma_node_type node_type) __attribute_const__; +__attribute_const__ enum rdma_transport_type +rdma_node_get_transport(enum rdma_node_type node_type);  enum rdma_link_layer {  	IB_LINK_LAYER_UNSPECIFIED, @@ -117,7 +122,19 @@ enum ib_device_cap_flags {  	IB_DEVICE_BLOCK_MULTICAST_LOOPBACK = (1<<22),  	IB_DEVICE_MEM_WINDOW_TYPE_2A	= (1<<23),  	IB_DEVICE_MEM_WINDOW_TYPE_2B	= (1<<24), -	IB_DEVICE_MANAGED_FLOW_STEERING = (1<<29) +	IB_DEVICE_MANAGED_FLOW_STEERING = (1<<29), +	IB_DEVICE_SIGNATURE_HANDOVER	= (1<<30) +}; + +enum ib_signature_prot_cap { +	IB_PROT_T10DIF_TYPE_1 = 1, +	IB_PROT_T10DIF_TYPE_2 = 1 << 1, +	IB_PROT_T10DIF_TYPE_3 = 1 << 2, +}; + +enum ib_signature_guard_cap { +	IB_GUARD_T10DIF_CRC	= 1, +	IB_GUARD_T10DIF_CSUM	= 1 << 1,  };  enum ib_atomic_cap { @@ -167,6 +184,8 @@ struct ib_device_attr {  	unsigned int		max_fast_reg_page_list_len;  	u16			max_pkeys;  	u8			local_ca_ack_delay; +	int			sig_prot_cap; +	int			sig_guard_cap;  };  enum ib_mtu { @@ -221,7 +240,8 @@ enum ib_port_cap_flags {  	IB_PORT_CAP_MASK_NOTICE_SUP		= 1 << 22,  	IB_PORT_BOOT_MGMT_SUP			= 1 << 23,  	IB_PORT_LINK_LATENCY_SUP		= 1 << 24, -	IB_PORT_CLIENT_REG_SUP			= 1 << 25 +	IB_PORT_CLIENT_REG_SUP			= 1 << 25, +	IB_PORT_IP_BASED_GIDS			= 1 << 26  };  enum ib_port_width { @@ -446,21 +466,145 @@ enum ib_rate {   * converted to 2, since 5 Gbit/sec is 2 * 2.5 Gbit/sec.   * @rate: rate to convert.   */ -int ib_rate_to_mult(enum ib_rate rate) __attribute_const__; +__attribute_const__ int ib_rate_to_mult(enum ib_rate rate);  /**   * ib_rate_to_mbps - Convert the IB rate enum to Mbps.   * For example, IB_RATE_2_5_GBPS will be converted to 2500.   * @rate: rate to convert.   */ -int ib_rate_to_mbps(enum ib_rate rate) __attribute_const__; +__attribute_const__ int ib_rate_to_mbps(enum ib_rate rate); + +enum ib_mr_create_flags { +	IB_MR_SIGNATURE_EN = 1, +}; + +/** + * ib_mr_init_attr - Memory region init attributes passed to routine + *     ib_create_mr. + * @max_reg_descriptors: max number of registration descriptors that + *     may be used with registration work requests. + * @flags: MR creation flags bit mask. + */ +struct ib_mr_init_attr { +	int	    max_reg_descriptors; +	u32	    flags; +}; + +enum ib_signature_type { +	IB_SIG_TYPE_T10_DIF, +}; + +/** + * T10-DIF Signature types + * T10-DIF types are defined by SCSI + * specifications. + */ +enum ib_t10_dif_type { +	IB_T10DIF_NONE, +	IB_T10DIF_TYPE1, +	IB_T10DIF_TYPE2, +	IB_T10DIF_TYPE3 +}; + +/** + * Signature T10-DIF block-guard types + * IB_T10DIF_CRC: Corresponds to T10-PI mandated CRC checksum rules. + * IB_T10DIF_CSUM: Corresponds to IP checksum rules. + */ +enum ib_t10_dif_bg_type { +	IB_T10DIF_CRC, +	IB_T10DIF_CSUM +}; + +/** + * struct ib_t10_dif_domain - Parameters specific for T10-DIF + *     domain. + * @type: T10-DIF type (0|1|2|3) + * @bg_type: T10-DIF block guard type (CRC|CSUM) + * @pi_interval: protection information interval. + * @bg: seed of guard computation. + * @app_tag: application tag of guard block + * @ref_tag: initial guard block reference tag. + * @type3_inc_reftag: T10-DIF type 3 does not state + *     about the reference tag, it is the user + *     choice to increment it or not. + */ +struct ib_t10_dif_domain { +	enum ib_t10_dif_type	type; +	enum ib_t10_dif_bg_type bg_type; +	u16			pi_interval; +	u16			bg; +	u16			app_tag; +	u32			ref_tag; +	bool			type3_inc_reftag; +}; + +/** + * struct ib_sig_domain - Parameters for signature domain + * @sig_type: specific signauture type + * @sig: union of all signature domain attributes that may + *     be used to set domain layout. + */ +struct ib_sig_domain { +	enum ib_signature_type sig_type; +	union { +		struct ib_t10_dif_domain dif; +	} sig; +}; + +/** + * struct ib_sig_attrs - Parameters for signature handover operation + * @check_mask: bitmask for signature byte check (8 bytes) + * @mem: memory domain layout desciptor. + * @wire: wire domain layout desciptor. + */ +struct ib_sig_attrs { +	u8			check_mask; +	struct ib_sig_domain	mem; +	struct ib_sig_domain	wire; +}; + +enum ib_sig_err_type { +	IB_SIG_BAD_GUARD, +	IB_SIG_BAD_REFTAG, +	IB_SIG_BAD_APPTAG, +}; + +/** + * struct ib_sig_err - signature error descriptor + */ +struct ib_sig_err { +	enum ib_sig_err_type	err_type; +	u32			expected; +	u32			actual; +	u64			sig_err_offset; +	u32			key; +}; + +enum ib_mr_status_check { +	IB_MR_CHECK_SIG_STATUS = 1, +}; + +/** + * struct ib_mr_status - Memory region status container + * + * @fail_status: Bitmask of MR checks status. For each + *     failed check a corresponding status bit is set. + * @sig_err: Additional info for IB_MR_CEHCK_SIG_STATUS + *     failure. + */ +struct ib_mr_status { +	u32		    fail_status; +	struct ib_sig_err   sig_err; +};  /**   * mult_to_ib_rate - Convert a multiple of 2.5 Gbit/sec to an IB rate   * enum.   * @mult: multiple to convert.   */ -enum ib_rate mult_to_ib_rate(int mult) __attribute_const__; +__attribute_const__ enum ib_rate mult_to_ib_rate(int mult);  struct ib_ah_attr {  	struct ib_global_route	grh; @@ -470,6 +614,8 @@ struct ib_ah_attr {  	u8			static_rate;  	u8			ah_flags;  	u8			port_num; +	u8			dmac[ETH_ALEN]; +	u16			vlan_id;  };  enum ib_wc_status { @@ -522,6 +668,8 @@ enum ib_wc_flags {  	IB_WC_WITH_IMM		= (1<<1),  	IB_WC_WITH_INVALIDATE	= (1<<2),  	IB_WC_IP_CSUM_OK	= (1<<3), +	IB_WC_WITH_SMAC		= (1<<4), +	IB_WC_WITH_VLAN		= (1<<5),  };  struct ib_wc { @@ -542,6 +690,8 @@ struct ib_wc {  	u8			sl;  	u8			dlid_path_bits;  	u8			port_num;	/* valid only for DR SMPs on switches */ +	u8			smac[ETH_ALEN]; +	u16			vlan_id;  };  enum ib_cq_notify_flags { @@ -631,6 +781,9 @@ enum ib_qp_type {  enum ib_qp_create_flags {  	IB_QP_CREATE_IPOIB_UD_LSO		= 1 << 0,  	IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK	= 1 << 1, +	IB_QP_CREATE_NETIF_QP			= 1 << 5, +	IB_QP_CREATE_SIGNATURE_EN		= 1 << 6, +	IB_QP_CREATE_USE_GFP_NOIO		= 1 << 7,  	/* reserve bits 26-31 for low level drivers' internal use */  	IB_QP_CREATE_RESERVED_START		= 1 << 26,  	IB_QP_CREATE_RESERVED_END		= 1 << 31, @@ -719,7 +872,11 @@ enum ib_qp_attr_mask {  	IB_QP_MAX_DEST_RD_ATOMIC	= (1<<17),  	IB_QP_PATH_MIG_STATE		= (1<<18),  	IB_QP_CAP			= (1<<19), -	IB_QP_DEST_QPN			= (1<<20) +	IB_QP_DEST_QPN			= (1<<20), +	IB_QP_SMAC			= (1<<21), +	IB_QP_ALT_SMAC			= (1<<22), +	IB_QP_VID			= (1<<23), +	IB_QP_ALT_VID			= (1<<24),  };  enum ib_qp_state { @@ -769,6 +926,10 @@ struct ib_qp_attr {  	u8			rnr_retry;  	u8			alt_port_num;  	u8			alt_timeout; +	u8			smac[ETH_ALEN]; +	u8			alt_smac[ETH_ALEN]; +	u16			vlan_id; +	u16			alt_vlan_id;  };  enum ib_wr_opcode { @@ -787,6 +948,7 @@ enum ib_wr_opcode {  	IB_WR_MASKED_ATOMIC_CMP_AND_SWP,  	IB_WR_MASKED_ATOMIC_FETCH_AND_ADD,  	IB_WR_BIND_MW, +	IB_WR_REG_SIG_MR,  	/* reserve values for low level drivers' internal use.  	 * These values will not be used at all in the ib core layer.  	 */ @@ -892,6 +1054,12 @@ struct ib_send_wr {  			u32                      rkey;  			struct ib_mw_bind_info   bind_info;  		} bind_mw; +		struct { +			struct ib_sig_attrs    *sig_attrs; +			struct ib_mr	       *sig_mr; +			int			access_flags; +			struct ib_sge	       *prot; +		} sig_handover;  	} wr;  	u32			xrc_remote_srq_num;	/* XRC TGT QPs only */  }; @@ -976,7 +1144,7 @@ struct ib_uobject {  };  struct ib_udata { -	void __user *inbuf; +	const void __user *inbuf;  	void __user *outbuf;  	size_t       inlen;  	size_t       outlen; @@ -1097,13 +1265,14 @@ enum ib_flow_attr_type {  enum ib_flow_spec_type {  	/* L2 headers*/  	IB_FLOW_SPEC_ETH	= 0x20, +	IB_FLOW_SPEC_IB		= 0x22,  	/* L3 header*/  	IB_FLOW_SPEC_IPV4	= 0x30,  	/* L4 headers*/  	IB_FLOW_SPEC_TCP	= 0x40,  	IB_FLOW_SPEC_UDP	= 0x41  }; - +#define IB_FLOW_SPEC_LAYER_MASK	0xF0  #define IB_FLOW_SPEC_SUPPORT_LAYERS 4  /* Flow steering rule priority is set according to it's domain. @@ -1131,6 +1300,18 @@ struct ib_flow_spec_eth {  	struct ib_flow_eth_filter mask;  }; +struct ib_flow_ib_filter { +	__be16 dlid; +	__u8   sl; +}; + +struct ib_flow_spec_ib { +	enum ib_flow_spec_type	 type; +	u16			 size; +	struct ib_flow_ib_filter val; +	struct ib_flow_ib_filter mask; +}; +  struct ib_flow_ipv4_filter {  	__be32	src_ip;  	__be32	dst_ip; @@ -1161,6 +1342,7 @@ union ib_flow_spec {  		u16			size;  	};  	struct ib_flow_spec_eth		eth; +	struct ib_flow_spec_ib		ib;  	struct ib_flow_spec_ipv4        ipv4;  	struct ib_flow_spec_tcp_udp	tcp_udp;  }; @@ -1231,10 +1413,6 @@ struct ib_dma_mapping_ops {  	void		(*unmap_sg)(struct ib_device *dev,  				    struct scatterlist *sg, int nents,  				    enum dma_data_direction direction); -	u64		(*dma_address)(struct ib_device *dev, -				       struct scatterlist *sg); -	unsigned int	(*dma_len)(struct ib_device *dev, -				   struct scatterlist *sg);  	void		(*sync_single_for_cpu)(struct ib_device *dev,  					       u64 dma_handle,  					       size_t size, @@ -1372,6 +1550,9 @@ struct ib_device {  	int                        (*query_mr)(struct ib_mr *mr,  					       struct ib_mr_attr *mr_attr);  	int                        (*dereg_mr)(struct ib_mr *mr); +	int                        (*destroy_mr)(struct ib_mr *mr); +	struct ib_mr *		   (*create_mr)(struct ib_pd *pd, +						struct ib_mr_init_attr *mr_init_attr);  	struct ib_mr *		   (*alloc_fast_reg_mr)(struct ib_pd *pd,  					       int max_page_list_len);  	struct ib_fast_reg_page_list * (*alloc_fast_reg_page_list)(struct ib_device *device, @@ -1420,6 +1601,8 @@ struct ib_device {  						  *flow_attr,  						  int domain);  	int			   (*destroy_flow)(struct ib_flow *flow_id); +	int			   (*check_mr_status)(struct ib_mr *mr, u32 check_mask, +						      struct ib_mr_status *mr_status);  	struct ib_dma_mapping_ops   *dma_ops; @@ -1436,6 +1619,7 @@ struct ib_device {  	int			     uverbs_abi_ver;  	u64			     uverbs_cmd_mask; +	u64			     uverbs_ex_cmd_mask;  	char			     node_desc[64];  	__be64			     node_guid; @@ -1485,6 +1669,7 @@ static inline int ib_copy_to_udata(struct ib_udata *udata, void *src, size_t len   * @next_state: Next QP state   * @type: QP type   * @mask: Mask of supplied QP attributes + * @ll : link layer of port   *   * This function is a helper function that a low-level driver's   * modify_qp method can use to validate the consumer's input.  It @@ -1493,7 +1678,8 @@ static inline int ib_copy_to_udata(struct ib_udata *udata, void *src, size_t len   * and that the attribute mask supplied is allowed for the transition.   */  int ib_modify_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state next_state, -		       enum ib_qp_type type, enum ib_qp_attr_mask mask); +		       enum ib_qp_type type, enum ib_qp_attr_mask mask, +		       enum rdma_link_layer ll);  int ib_register_event_handler  (struct ib_event_handler *event_handler);  int ib_unregister_event_handler(struct ib_event_handler *event_handler); @@ -2051,12 +2237,13 @@ static inline void ib_dma_unmap_sg_attrs(struct ib_device *dev,   * ib_sg_dma_address - Return the DMA address from a scatter/gather entry   * @dev: The device for which the DMA addresses were created   * @sg: The scatter/gather entry + * + * Note: this function is obsolete. To do: change all occurrences of + * ib_sg_dma_address() into sg_dma_address().   */  static inline u64 ib_sg_dma_address(struct ib_device *dev,  				    struct scatterlist *sg)  { -	if (dev->dma_ops) -		return dev->dma_ops->dma_address(dev, sg);  	return sg_dma_address(sg);  } @@ -2064,12 +2251,13 @@ static inline u64 ib_sg_dma_address(struct ib_device *dev,   * ib_sg_dma_len - Return the DMA length from a scatter/gather entry   * @dev: The device for which the DMA addresses were created   * @sg: The scatter/gather entry + * + * Note: this function is obsolete. To do: change all occurrences of + * ib_sg_dma_len() into sg_dma_len().   */  static inline unsigned int ib_sg_dma_len(struct ib_device *dev,  					 struct scatterlist *sg)  { -	if (dev->dma_ops) -		return dev->dma_ops->dma_len(dev, sg);  	return sg_dma_len(sg);  } @@ -2212,6 +2400,25 @@ int ib_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr);   */  int ib_dereg_mr(struct ib_mr *mr); + +/** + * ib_create_mr - Allocates a memory region that may be used for + *     signature handover operations. + * @pd: The protection domain associated with the region. + * @mr_init_attr: memory region init attributes. + */ +struct ib_mr *ib_create_mr(struct ib_pd *pd, +			   struct ib_mr_init_attr *mr_init_attr); + +/** + * ib_destroy_mr - Destroys a memory region that was created using + *     ib_create_mr and removes it from HW translation tables. + * @mr: The memory region to destroy. + * + * This function can fail, if the memory region has memory windows bound to it. + */ +int ib_destroy_mr(struct ib_mr *mr); +  /**   * ib_alloc_fast_reg_mr - Allocates memory region usable with the   *   IB_WR_FAST_REG_MR send work request. @@ -2384,4 +2591,32 @@ struct ib_flow *ib_create_flow(struct ib_qp *qp,  			       struct ib_flow_attr *flow_attr, int domain);  int ib_destroy_flow(struct ib_flow *flow_id); +static inline int ib_check_mr_access(int flags) +{ +	/* +	 * Local write permission is required if remote write or +	 * remote atomic permission is also requested. +	 */ +	if (flags & (IB_ACCESS_REMOTE_ATOMIC | IB_ACCESS_REMOTE_WRITE) && +	    !(flags & IB_ACCESS_LOCAL_WRITE)) +		return -EINVAL; + +	return 0; +} + +/** + * ib_check_mr_status: lightweight check of MR status. + *     This routine may provide status checks on a selected + *     ib_mr. first use is for signature status check. + * + * @mr: A memory region. + * @check_mask: Bitmask of which checks to perform from + *     ib_mr_status_check enumeration. + * @mr_status: The container of relevant status checks. + *     failed checks will be indicated in the status bitmask + *     and the relevant info shall be in the error item. + */ +int ib_check_mr_status(struct ib_mr *mr, u32 check_mask, +		       struct ib_mr_status *mr_status); +  #endif /* IB_VERBS_H */ diff --git a/include/rdma/iw_portmap.h b/include/rdma/iw_portmap.h new file mode 100644 index 00000000000..928b2775e99 --- /dev/null +++ b/include/rdma/iw_portmap.h @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2014 Intel Corporation. All rights reserved. + * Copyright (c) 2014 Chelsio, Inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses.  You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + *     Redistribution and use in source and binary forms, with or + *     without modification, are permitted provided that the following + *     conditions are met: + * + *      - Redistributions of source code must retain the above + *	  copyright notice, this list of conditions and the following + *	  disclaimer. + * + *      - Redistributions in binary form must reproduce the above + *	  copyright notice, this list of conditions and the following + *	  disclaimer in the documentation and/or other materials + *	  provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef _IW_PORTMAP_H +#define _IW_PORTMAP_H + +#define IWPM_ULIBNAME_SIZE	32 +#define IWPM_DEVNAME_SIZE	32 +#define IWPM_IFNAME_SIZE	16 +#define IWPM_IPADDR_SIZE	16 + +enum { +	IWPM_INVALID_NLMSG_ERR = 10, +	IWPM_CREATE_MAPPING_ERR, +	IWPM_DUPLICATE_MAPPING_ERR, +	IWPM_UNKNOWN_MAPPING_ERR, +	IWPM_CLIENT_DEV_INFO_ERR, +	IWPM_USER_LIB_INFO_ERR, +	IWPM_REMOTE_QUERY_REJECT +}; + +struct iwpm_dev_data { +	char dev_name[IWPM_DEVNAME_SIZE]; +	char if_name[IWPM_IFNAME_SIZE]; +}; + +struct iwpm_sa_data { +	struct sockaddr_storage loc_addr; +	struct sockaddr_storage mapped_loc_addr; +	struct sockaddr_storage rem_addr; +	struct sockaddr_storage mapped_rem_addr; +}; + +/** + * iwpm_init - Allocate resources for the iwarp port mapper + * + * Should be called when network interface goes up. + */ +int iwpm_init(u8); + +/** + * iwpm_exit - Deallocate resources for the iwarp port mapper + * + * Should be called when network interface goes down. + */ +int iwpm_exit(u8); + +/** + * iwpm_valid_pid - Check if the userspace iwarp port mapper pid is valid + * + * Returns true if the pid is greater than zero, otherwise returns false + */ +int iwpm_valid_pid(void); + +/** + * iwpm_register_pid - Send a netlink query to userspace + *                     to get the iwarp port mapper pid + * @pm_msg: Contains driver info to send to the userspace port mapper + * @nl_client: The index of the netlink client + */ +int iwpm_register_pid(struct iwpm_dev_data *pm_msg, u8 nl_client); + +/** + * iwpm_add_mapping - Send a netlink add mapping request to + *                    the userspace port mapper + * @pm_msg: Contains the local ip/tcp address info to send + * @nl_client: The index of the netlink client + * + * If the request is successful, the pm_msg stores + * the port mapper response (mapped address info) + */ +int iwpm_add_mapping(struct iwpm_sa_data *pm_msg, u8 nl_client); + +/** + * iwpm_add_and_query_mapping - Send a netlink add and query mapping request + *				 to the userspace port mapper + * @pm_msg: Contains the local and remote ip/tcp address info to send + * @nl_client: The index of the netlink client + * + * If the request is successful, the pm_msg stores the + * port mapper response (mapped local and remote address info) + */ +int iwpm_add_and_query_mapping(struct iwpm_sa_data *pm_msg, u8 nl_client); + +/** + * iwpm_remove_mapping - Send a netlink remove mapping request + *                       to the userspace port mapper + * + * @local_addr: Local ip/tcp address to remove + * @nl_client: The index of the netlink client + */ +int iwpm_remove_mapping(struct sockaddr_storage *local_addr, u8 nl_client); + +/** + * iwpm_register_pid_cb - Process the port mapper response to + *                        iwpm_register_pid query + * @skb: + * @cb: Contains the received message (payload and netlink header) + * + * If successful, the function receives the userspace port mapper pid + * which is used in future communication with the port mapper + */ +int iwpm_register_pid_cb(struct sk_buff *, struct netlink_callback *); + +/** + * iwpm_add_mapping_cb - Process the port mapper response to + *                       iwpm_add_mapping request + * @skb: + * @cb: Contains the received message (payload and netlink header) + */ +int iwpm_add_mapping_cb(struct sk_buff *, struct netlink_callback *); + +/** + * iwpm_add_and_query_mapping_cb - Process the port mapper response to + *                                 iwpm_add_and_query_mapping request + * @skb: + * @cb: Contains the received message (payload and netlink header) + */ +int iwpm_add_and_query_mapping_cb(struct sk_buff *, struct netlink_callback *); + +/** + * iwpm_mapping_error_cb - Process port mapper notification for error + * + * @skb: + * @cb: Contains the received message (payload and netlink header) + */ +int iwpm_mapping_error_cb(struct sk_buff *, struct netlink_callback *); + +/** + * iwpm_mapping_info_cb - Process a notification that the userspace + *                        port mapper daemon is started + * @skb: + * @cb: Contains the received message (payload and netlink header) + * + * Using the received port mapper pid, send all the local mapping + * info records to the userspace port mapper + */ +int iwpm_mapping_info_cb(struct sk_buff *, struct netlink_callback *); + +/** + * iwpm_ack_mapping_info_cb - Process the port mapper ack for + *                            the provided local mapping info records + * @skb: + * @cb: Contains the received message (payload and netlink header) + */ +int iwpm_ack_mapping_info_cb(struct sk_buff *, struct netlink_callback *); + +/** + * iwpm_create_mapinfo - Store local and mapped IPv4/IPv6 address + *                       info in a hash table + * @local_addr: Local ip/tcp address + * @mapped_addr: Mapped local ip/tcp address + * @nl_client: The index of the netlink client + */ +int iwpm_create_mapinfo(struct sockaddr_storage *local_addr, +			struct sockaddr_storage *mapped_addr, u8 nl_client); + +/** + * iwpm_remove_mapinfo - Remove local and mapped IPv4/IPv6 address + *                       info from the hash table + * @local_addr: Local ip/tcp address + * @mapped_addr: Mapped local ip/tcp address + * + * Returns err code if mapping info is not found in the hash table, + * otherwise returns 0 + */ +int iwpm_remove_mapinfo(struct sockaddr_storage *local_addr, +			struct sockaddr_storage *mapped_addr); + +#endif /* _IW_PORTMAP_H */ diff --git a/include/rdma/rdma_netlink.h b/include/rdma/rdma_netlink.h index e38de79eeb4..0790882e0c9 100644 --- a/include/rdma/rdma_netlink.h +++ b/include/rdma/rdma_netlink.h @@ -43,7 +43,7 @@ int ibnl_remove_client(int index);   * Returns the allocated buffer on success and NULL on failure.   */  void *ibnl_put_msg(struct sk_buff *skb, struct nlmsghdr **nlh, int seq, -		   int len, int client, int op); +		   int len, int client, int op, int flags);  /**   * Put a new attribute in a supplied skb.   * @skb: The netlink skb. @@ -56,4 +56,25 @@ void *ibnl_put_msg(struct sk_buff *skb, struct nlmsghdr **nlh, int seq,  int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,  		  int len, void *data, int type); +/** + * Send the supplied skb to a specific userspace PID. + * @skb: The netlink skb + * @nlh: Header of the netlink message to send + * @pid: Userspace netlink process ID + * Returns 0 on success or a negative error code. + */ +int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh, +			__u32 pid); + +/** + * Send the supplied skb to a netlink group. + * @skb: The netlink skb + * @nlh: Header of the netlink message to send + * @group: Netlink group ID + * @flags: allocation flags + * Returns 0 on success or a negative error code. + */ +int ibnl_multicast(struct sk_buff *skb, struct nlmsghdr *nlh, +			unsigned int group, gfp_t flags); +  #endif /* _RDMA_NETLINK_H */  | 
