---
name: "ibv_create_wq"
section: "3"
platform: "linux"
package: "rdma-core"
version: "65.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/ibv_create_wq"
---

# ibv\_create\_wq(3)

create or destroy a Work Queue (WQ).

## NAME

ibv\_create\_wq, ibv\_destroy\_wq - create or destroy a Work Queue (WQ).

## SYNOPSIS

```
#include <infiniband/verbs.h>

struct ibv_wq *ibv_create_wq(struct ibv_context *context,
                                     struct ibv_wq_init_attr *wq_init_attr);

int ibv_destroy_wq(struct ibv_wq *wq);
```

## DESCRIPTION

**ibv\_create\_wq()** creates a WQ associated with the ibv\_context *context.* The argument *wq\_init\_attr* is an ibv\_wq\_init\_attr struct, as defined in \<infiniband/verbs.h\>.

```
struct ibv_wq_init_attr {
void                      *wq_context;    /* Associated context of the WQ */
enum ibv_wq_type           wq_type;       /* WQ type */
uint32_t                   max_wr;        /* Requested max number of outstanding WRs in the WQ */
uint32_t                   max_sge;       /* Requested max number of scatter/gather (s/g) elements per WR in the WQ */
struct  ibv_pd            *pd;            /* PD to be associated with the WQ */
struct  ibv_cq            *cq;            /* CQ to be associated with the WQ */
uint32_t                   comp_mask;     /* Identifies valid fields. Use ibv_wq_init_attr_mask */
uint32_t                   create_flags    /* Creation flags for this WQ, use enum ibv_wq_flags */
};

enum ibv_wq_flags {
IBV_WQ_FLAGS_CVLAN_STRIPPING            = 1 << 0, /* CVLAN field will be stripped from incoming packets */
IBV_WQ_FLAGS_SCATTER_FCS                = 1 << 1, /* FCS field will be scattered to host memory */
IBV_WQ_FLAGS_DELAY_DROP                 = 1 << 2, /* Packets won't be dropped immediately if no receive WQEs */
IBV_WQ_FLAGS_PCI_WRITE_END_PADDING      = 1 << 3, /* Incoming packets will be padded to cacheline size */
IBV_WQ_FLAGS_RESERVED                   = 1 << 4,
};
```

The function **ibv\_create\_wq()** will update the *wq\_init\_attr-\>max\_wr* and *wq\_init\_attr-\>max\_sge* fields with the actual WQ values of the WQ that was created; the values will be greater than or equal to the values requested.

**ibv\_destroy\_wq()** destroys the WQ *wq.*

## RETURN VALUE

**ibv\_create\_wq()** returns a pointer to the created WQ, or NULL if the request fails.

**ibv\_destroy\_wq()** returns 0 on success, or the value of errno on failure (which indicates the failure reason).

## SEE ALSO

[**ibv\_modify\_wq**(3)](/ibv_modify_wq/3.md),

## AUTHORS

- Yishai Hadas \<yishaih@mellanox.com\>
