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

# umad\_get\_port(3)

open and close an InfiniBand port

## NAME

umad\_get\_port, umad\_release\_port - open and close an InfiniBand port

## SYNOPSIS

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

int umad_get_port(char *ca_name, int portnum, umad_port_t *port);

int umad_release_port(umad_port_t *port);
```

## DESCRIPTION

**umad\_get\_port()** fills the *port* structure with the IB port attributes specified by *ca\_name* and *portnum* , or the default port if *ca\_name* is NULL and *portnum* is zero. If only one of *ca\_name* and *portnum* are specified, the other is used as a filter. For example, passing a NULL *ca\_name* and 2 for the *portnum* means get a port from any of the local IB devices, as long as it is the second port. Note that the library may use some reference scheme to support port caching therefore **umad\_release\_port()** should be called before the *port* structure can be deallocated. The argument *port* is an **umad\_port\_t** struct, as specified in \<infiniband/umad.h\>.

```
typedef struct umad_port {
char ca_name[UMAD_CA_NAME_LEN];                 /* Name of the device */
int portnum;                                    /* Physical port number */
uint base_lid;                                  /* Base port LID */
uint lmc;                                       /* LMC of LID */
uint sm_lid;                                    /* SM LID */
uint sm_sl;                                     /* SM service level */
uint state;                                     /* Logical port state */
uint phys_state;                                /* Physical port state */
uint rate;                                      /* Port link bit rate */
uint64_t capmask;                               /* Port capabilities */
uint64_t gid_prefix;                            /* Gid prefix of this port */
uint64_t port_guid;                             /* GUID of this port */
} umad_port_t;
```

**umad\_release\_port()** releases the resources that were allocated by the **umad\_get\_port()** function for the specified IB *port.*

## RETURN VALUE

**umad\_get\_port()** and **umad\_release\_port()** return 0 on success, and a negative value on error.

## AUTHORS

- Hal Rosenstock \<halr@voltaire.com\>

  - Dotan Barak \<dotanb@mellanox.co.il\>
