Re: [PATCH rdma-next v2 03/11] RDMA/efa: Add the efa.h header file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 26-Feb-19 20:03, Steve Wise wrote:
>> +#define efa_stat_inc(dev, stat)                                         \
>> +	do {                                                            \
>> +		typeof(dev) _dev = dev;                                 \
>> +		unsigned long flags;                                    \
>> +									\
>> +		spin_lock_irqsave(&_dev->stats_lock, flags);            \
>> +		(stat)++;                                               \
>> +		spin_unlock_irqrestore(&_dev->stats_lock, flags);       \
>> +	} while (0)
>> +
> 
> 
> Would this be more safe as a static inline function where you explicitly
> type the parameters?

The typeof looks like an overkill.
I prefer to keep it as a define, but I will thin it down a little.

> 
> 
>> +enum {
>> +	EFA_DEVICE_RUNNING_BIT,
>> +	EFA_MSIX_ENABLED_BIT
>> +};
>> +
>> +struct efa_dev {
>> +	struct ib_device        ibdev;
>> +	struct pci_dev         *pdev;
>> +	struct efa_com_dev     *edev;
>> +	struct efa_com_get_device_attr_result dev_attr;
>> +
>> +	u64                     reg_bar_addr;
>> +	u64                     reg_bar_len;
>> +	u64                     mem_bar_addr;
>> +	u64                     mem_bar_len;
>> +	u64                     db_bar_addr;
>> +	u64                     db_bar_len;
>> +	u8                      addr[EFA_GID_SIZE];
> 
> 
> Is the GID size really EFA-specific?  Or can some core #define be used?

It's not EFA specific but I'm not familiar with an existing define that can be
used here.

> 
> 
>> +	u32                     mtu;
>> +
>> +	int                     admin_msix_vector_idx;
>> +	unsigned long           state;
>> +	struct efa_irq          admin_irq;
>> +
>> +	struct efa_stats        stats;
>> +	spinlock_t              stats_lock; /* Protects stats */
>> +};
>> +
>> +struct efa_ucontext {
>> +	struct ib_ucontext      ibucontext;
>> +	/* Protects ucontext state */
>> +	struct mutex            lock;
>> +	struct list_head        pending_mmaps;
>> +	u64                     mmap_key;
>> +	u16                     uarn;
>> +};
>> +
>> +struct efa_pd {
>> +	struct ib_pd    ibpd;
>> +	u16             pdn;
>> +};
>> +
>> +struct efa_mr {
>> +	struct ib_mr     ibmr;
>> +	struct ib_umem  *umem;
>> +};
>> +
>> +struct efa_cq {
>> +	struct ib_cq               ibcq;
>> +	struct efa_ucontext       *ucontext;
>> +	dma_addr_t                 dma_addr;
>> +	void                      *cpu_addr;
>> +	size_t                     size;
>> +	u16                        cq_idx;
>> +};
>> +
>> +struct efa_qp {
>> +	struct ib_qp            ibqp;
>> +	dma_addr_t              rq_dma_addr;
>> +	void                   *rq_cpu_addr;
>> +	size_t                  rq_size;
>> +	enum ib_qp_state        state;
>> +	u32                     qp_handle;
>> +	u32                     max_send_wr;
>> +	u32                     max_recv_wr;
>> +	u32                     max_send_sge;
>> +	u32                     max_recv_sge;
>> +	u32                     max_inline_data;
>> +};
>> +
>> +struct efa_ah {
>> +	struct ib_ah    ibah;
>> +	u16             ah;
>> +	/* dest_addr */
>> +	u8              id[EFA_GID_SIZE];
>> +};
>> +
>> +int efa_query_device(struct ib_device *ibdev,
>> +		     struct ib_device_attr *props,
>> +		     struct ib_udata *udata);
>> +int efa_query_port(struct ib_device *ibdev, u8 port,
>> +		   struct ib_port_attr *props);
>> +int efa_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
>> +		 int qp_attr_mask,
>> +		 struct ib_qp_init_attr *qp_init_attr);
>> +int efa_query_gid(struct ib_device *ibdev, u8 port, int index,
>> +		  union ib_gid *gid);
>> +int efa_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
>> +		   u16 *pkey);
>> +int efa_alloc_pd(struct ib_pd *ibpd,
>> +		 struct ib_ucontext *ibucontext,
>> +		 struct ib_udata *udata);
>> +void efa_dealloc_pd(struct ib_pd *ibpd);
>> +int efa_destroy_qp_handle(struct efa_dev *dev, u32 qp_handle);
>> +int efa_destroy_qp(struct ib_qp *ibqp);
>> +struct ib_qp *efa_create_qp(struct ib_pd *ibpd,
>> +			    struct ib_qp_init_attr *init_attr,
>> +			    struct ib_udata *udata);
>> +int efa_destroy_cq(struct ib_cq *ibcq);
>> +struct ib_cq *efa_create_cq(struct ib_device *ibdev,
>> +			    const struct ib_cq_init_attr *attr,
>> +			    struct ib_ucontext *ibucontext,
>> +			    struct ib_udata *udata);
>> +struct ib_mr *efa_reg_mr(struct ib_pd *ibpd, u64 start, u64 length,
>> +			 u64 virt_addr, int access_flags,
>> +			 struct ib_udata *udata);
>> +int efa_dereg_mr(struct ib_mr *ibmr);
>> +int efa_get_port_immutable(struct ib_device *ibdev, u8 port_num,
>> +			   struct ib_port_immutable *immutable);
>> +struct ib_ucontext *efa_alloc_ucontext(struct ib_device *ibdev,
>> +				       struct ib_udata *udata);
>> +int efa_dealloc_ucontext(struct ib_ucontext *ibucontext);
>> +int efa_mmap(struct ib_ucontext *ibucontext,
>> +	     struct vm_area_struct *vma);
>> +struct ib_ah *efa_create_ah(struct ib_pd *ibpd,
>> +			    struct rdma_ah_attr *ah_attr,
>> +			    u32 flags,
>> +			    struct ib_udata *udata);
>> +int efa_destroy_ah(struct ib_ah *ibah, u32 flags);
>> +int efa_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
>> +		  int qp_attr_mask, struct ib_udata *udata);
>> +enum rdma_link_layer efa_port_link_layer(struct ib_device *ibdev,
>> +					 u8 port_num);
>> +
>> +#endif /* _EFA_H_ */
> 
> 
> Reviewed-by: Steve Wise <swise@xxxxxxxxxxxxxxxxxxxxx>
> 
> 

Thanks Steve!



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux