drivers/infiniband/hw/mana/main.c

Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/mana/main.c

File Facts

System
Linux kernel
Corpus path
drivers/infiniband/hw/mana/main.c
Extension
.c
Size
32141 bytes
Lines
1102
Domain
Driver Families
Bucket
drivers/infiniband
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (pd->vport_port != port) {
			pd->vport_use_count--;
			mutex_unlock(&pd->vport_mutex);
			ibdev_dbg(&dev->ib_dev,
				  "PD already bound to port %u\n",
				  pd->vport_port);
			return -EINVAL;
		}
		ibdev_dbg(&dev->ib_dev,
			  "Skip as this PD is already configured vport\n");
		mutex_unlock(&pd->vport_mutex);
		return 0;
	}

	pd->vport_port = port;

	err = mana_cfg_vport(mpc, pd->pdn, doorbell_id, true);
	if (err) {
		pd->vport_use_count--;
		mutex_unlock(&pd->vport_mutex);

		ibdev_dbg(&dev->ib_dev, "Failed to configure vPort %d\n", err);
		return err;
	}


	err = mana_create_eq(mpc);
	if (err) {
		mana_uncfg_vport(mpc);
		pd->vport_use_count--;
	} else {
		pd->tx_shortform_allowed = mpc->tx_shortform_allowed;
		pd->tx_vp_offset = mpc->tx_vp_offset;
	}

	mutex_unlock(&pd->vport_mutex);

	if (!err)
		ibdev_dbg(&dev->ib_dev, "vport handle %llx pdid %x doorbell_id %x\n",
			  mpc->port_handle, pd->pdn, doorbell_id);

	return err;
}

int mana_ib_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)
{
	struct mana_ib_pd *pd = container_of(ibpd, struct mana_ib_pd, ibpd);
	struct ib_device *ibdev = ibpd->device;
	struct gdma_create_pd_resp resp = {};
	struct gdma_create_pd_req req = {};
	enum gdma_pd_flags flags = 0;
	struct mana_ib_dev *dev;
	struct gdma_context *gc;
	int err;

	dev = container_of(ibdev, struct mana_ib_dev, ib_dev);
	gc = mdev_to_gc(dev);

	mana_gd_init_req_hdr(&req.hdr, GDMA_CREATE_PD, sizeof(req),
			     sizeof(resp));

	if (!udata)
		flags |= GDMA_PD_FLAG_ALLOW_GPA_MR;

	req.flags = flags;
	err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp);
	if (err)
		return err;

	pd->pd_handle = resp.pd_handle;
	pd->pdn = resp.pd_id;
	ibdev_dbg(&dev->ib_dev, "pd_handle 0x%llx pd_id %d\n",
		  pd->pd_handle, pd->pdn);

	mutex_init(&pd->vport_mutex);
	pd->vport_use_count = 0;
	return 0;
}

int mana_ib_dealloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)
{
	struct mana_ib_pd *pd = container_of(ibpd, struct mana_ib_pd, ibpd);
	struct ib_device *ibdev = ibpd->device;
	struct gdma_destory_pd_resp resp = {};
	struct gdma_destroy_pd_req req = {};
	struct mana_ib_dev *dev;
	struct gdma_context *gc;

	dev = container_of(ibdev, struct mana_ib_dev, ib_dev);
	gc = mdev_to_gc(dev);

Annotation

Implementation Notes