Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 81821644 authored by Tatyana Nikolova's avatar Tatyana Nikolova Committed by Roland Dreier
Browse files

RDMA/nes: Print hardware resource type



Hardware resource types are added and when a resource isn't available,
its type is printed.

Signed-off-by: default avatarTatyana Nikolova <Tatyana.E.Nikolova@intel.com>
Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
parent fc4ba729
Loading
Loading
Loading
Loading
+12 −3
Original line number Original line Diff line number Diff line
@@ -399,11 +399,20 @@ static inline void nes_write8(void __iomem *addr, u8 val)
	writeb(val, addr);
	writeb(val, addr);
}
}



enum nes_resource {
	NES_RESOURCE_MW = 1,
	NES_RESOURCE_FAST_MR,
	NES_RESOURCE_PHYS_MR,
	NES_RESOURCE_USER_MR,
	NES_RESOURCE_PD,
	NES_RESOURCE_QP,
	NES_RESOURCE_CQ,
	NES_RESOURCE_ARP
};


static inline int nes_alloc_resource(struct nes_adapter *nesadapter,
static inline int nes_alloc_resource(struct nes_adapter *nesadapter,
		unsigned long *resource_array, u32 max_resources,
		unsigned long *resource_array, u32 max_resources,
		u32 *req_resource_num, u32 *next)
		u32 *req_resource_num, u32 *next, enum nes_resource resource_type)
{
{
	unsigned long flags;
	unsigned long flags;
	u32 resource_num;
	u32 resource_num;
@@ -414,7 +423,7 @@ static inline int nes_alloc_resource(struct nes_adapter *nesadapter,
	if (resource_num >= max_resources) {
	if (resource_num >= max_resources) {
		resource_num = find_first_zero_bit(resource_array, max_resources);
		resource_num = find_first_zero_bit(resource_array, max_resources);
		if (resource_num >= max_resources) {
		if (resource_num >= max_resources) {
			printk(KERN_ERR PFX "%s: No available resourcess.\n", __func__);
			printk(KERN_ERR PFX "%s: No available resources [type=%u].\n", __func__, resource_type);
			spin_unlock_irqrestore(&nesadapter->resource_lock, flags);
			spin_unlock_irqrestore(&nesadapter->resource_lock, flags);
			return -EMFILE;
			return -EMFILE;
		}
		}
+1 −1
Original line number Original line Diff line number Diff line
@@ -699,7 +699,7 @@ int nes_arp_table(struct nes_device *nesdev, u32 ip_addr, u8 *mac_addr, u32 acti


		arp_index = 0;
		arp_index = 0;
		err = nes_alloc_resource(nesadapter, nesadapter->allocated_arps,
		err = nes_alloc_resource(nesadapter, nesadapter->allocated_arps,
				nesadapter->arp_table_size, (u32 *)&arp_index, &nesadapter->next_arp_index);
				nesadapter->arp_table_size, (u32 *)&arp_index, &nesadapter->next_arp_index, NES_RESOURCE_ARP);
		if (err) {
		if (err) {
			nes_debug(NES_DBG_NETDEV, "nes_alloc_resource returned error = %u\n", err);
			nes_debug(NES_DBG_NETDEV, "nes_alloc_resource returned error = %u\n", err);
			return err;
			return err;
+7 −7
Original line number Original line Diff line number Diff line
@@ -80,7 +80,7 @@ static struct ib_mw *nes_alloc_mw(struct ib_pd *ibpd) {
	next_stag_index %= nesadapter->max_mr;
	next_stag_index %= nesadapter->max_mr;


	ret = nes_alloc_resource(nesadapter, nesadapter->allocated_mrs,
	ret = nes_alloc_resource(nesadapter, nesadapter->allocated_mrs,
			nesadapter->max_mr, &stag_index, &next_stag_index);
			nesadapter->max_mr, &stag_index, &next_stag_index, NES_RESOURCE_MW);
	if (ret) {
	if (ret) {
		return ERR_PTR(ret);
		return ERR_PTR(ret);
	}
	}
@@ -404,7 +404,7 @@ static struct ib_mr *nes_alloc_fast_reg_mr(struct ib_pd *ibpd, int max_page_list


	err = nes_alloc_resource(nesadapter, nesadapter->allocated_mrs,
	err = nes_alloc_resource(nesadapter, nesadapter->allocated_mrs,
				 nesadapter->max_mr, &stag_index,
				 nesadapter->max_mr, &stag_index,
				 &next_stag_index);
				 &next_stag_index, NES_RESOURCE_FAST_MR);
	if (err)
	if (err)
		return ERR_PTR(err);
		return ERR_PTR(err);


@@ -780,7 +780,7 @@ static struct ib_pd *nes_alloc_pd(struct ib_device *ibdev,
			netdev_refcnt_read(nesvnic->netdev));
			netdev_refcnt_read(nesvnic->netdev));


	err = nes_alloc_resource(nesadapter, nesadapter->allocated_pds,
	err = nes_alloc_resource(nesadapter, nesadapter->allocated_pds,
			nesadapter->max_pd, &pd_num, &nesadapter->next_pd);
			nesadapter->max_pd, &pd_num, &nesadapter->next_pd, NES_RESOURCE_PD);
	if (err) {
	if (err) {
		return ERR_PTR(err);
		return ERR_PTR(err);
	}
	}
@@ -1157,7 +1157,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
			nes_debug(NES_DBG_QP, "RQ size=%u, SQ Size=%u\n", rq_size, sq_size);
			nes_debug(NES_DBG_QP, "RQ size=%u, SQ Size=%u\n", rq_size, sq_size);


			ret = nes_alloc_resource(nesadapter, nesadapter->allocated_qps,
			ret = nes_alloc_resource(nesadapter, nesadapter->allocated_qps,
					nesadapter->max_qp, &qp_num, &nesadapter->next_qp);
					nesadapter->max_qp, &qp_num, &nesadapter->next_qp, NES_RESOURCE_QP);
			if (ret) {
			if (ret) {
				return ERR_PTR(ret);
				return ERR_PTR(ret);
			}
			}
@@ -1546,7 +1546,7 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries,
		return ERR_PTR(-EINVAL);
		return ERR_PTR(-EINVAL);


	err = nes_alloc_resource(nesadapter, nesadapter->allocated_cqs,
	err = nes_alloc_resource(nesadapter, nesadapter->allocated_cqs,
			nesadapter->max_cq, &cq_num, &nesadapter->next_cq);
			nesadapter->max_cq, &cq_num, &nesadapter->next_cq, NES_RESOURCE_CQ);
	if (err) {
	if (err) {
		return ERR_PTR(err);
		return ERR_PTR(err);
	}
	}
@@ -2129,7 +2129,7 @@ static struct ib_mr *nes_reg_phys_mr(struct ib_pd *ib_pd,
		return ERR_PTR(-EINVAL);
		return ERR_PTR(-EINVAL);


	err = nes_alloc_resource(nesadapter, nesadapter->allocated_mrs, nesadapter->max_mr,
	err = nes_alloc_resource(nesadapter, nesadapter->allocated_mrs, nesadapter->max_mr,
			&stag_index, &next_stag_index);
			&stag_index, &next_stag_index, NES_RESOURCE_PHYS_MR);
	if (err) {
	if (err) {
		return ERR_PTR(err);
		return ERR_PTR(err);
	}
	}
@@ -2360,7 +2360,7 @@ static struct ib_mr *nes_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
			next_stag_index %= nesadapter->max_mr;
			next_stag_index %= nesadapter->max_mr;


			err = nes_alloc_resource(nesadapter, nesadapter->allocated_mrs,
			err = nes_alloc_resource(nesadapter, nesadapter->allocated_mrs,
					nesadapter->max_mr, &stag_index, &next_stag_index);
					nesadapter->max_mr, &stag_index, &next_stag_index, NES_RESOURCE_USER_MR);
			if (err) {
			if (err) {
				ib_umem_release(region);
				ib_umem_release(region);
				return ERR_PTR(err);
				return ERR_PTR(err);