summaryrefslogtreecommitdiff
path: root/documentation/6.components/device-driver/rpmsg/ns.md
blob: 53763a8ce7dbcd6b64fec4ab913098bb8a894bb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
@page page_device_rpmsg_ns RPMsg name service

# RPMsg name service (`rpmsg_ns.c`)

**`RT_RPMSG_DRIVER_EXPORT(rpmsg_ns_driver)`** — matches **`id.name = "rpmsg-name-service"`** (second **`rt_rpmsg_device`** from **`virtio-rpmsg.c`** when **`VIRTIO_RPMSG_F_NS`**).

Stack context: @ref page_device_rpmsg.

---

## Fixed endpoint

**`rpmsg_ns_probe`** creates:

| Field | Value |
| --- | --- |
| **`info.name`** | `"name-service"` |
| **`src` / `dst`** | **`RT_RPMSG_NS_ADDR` (0x35)** |
| RX | **`rpmsg_ns_rx_callback`** |

---

## Wire message

```c
struct rt_rpmsg_ns_msg {
    char name[32];
    le32 addr;
    le32 flags;   /* RT_RPMSG_NS_CREATE or RT_RPMSG_NS_DESTROY */
};
```

**`rpmsg_ns_rx_callback`**:

| Flag | Action |
| --- | --- |
| **CREATE** | **`rt_rpmsg_create_endpoint(rdev, &info, NULL)`** → driver **`rx_callback`** fallback |
| **DESTROY** | **`find_endpoint`** + **`destroy_endpoint`** |

**`virtio_rpmsg`** routes packets with **`dst == 0x35`** to **`vrpmsg->ns`** device, not the char device.

---

## Local CREATE side

When **`virtio_rpmsg_create_endpoint`** runs on a **local** endpoint and **`supp_ns`**:

- Sends **NS CREATE** to **`RT_RPMSG_NS_ADDR`** with **`addr = ept->info.src`** (little-endian on wire)

Remote can then open the announced channel.

---

## Pitfalls

| Issue | Mitigation |
| --- | --- |
| **Endianness** | **`addr`** is **le32** on wire |
| **CREATE without consumer** | Orphan endpoints until DESTROY |
| **Only master has NS feature** | **`rpmsg_virtio_get_features`** sets **`VIRTIO_RPMSG_F_NS`** on master |

---

## See also

- @ref page_device_rpmsg
- @ref page_device_rpmsg_char
- `components/drivers/rpmsg/rpmsg_ns.c`