docs: networking: convert phonet.txt to ReST

- add SPDX header;
- adjust title markup;
- use copyright symbol;
- add notes markups;
- mark code blocks and literals as such;
- adjust identation, whitespaces and blank lines where needed;
- add to networking/index.rst.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Acked-by: Rémi Denis-Courmont <courmisch@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Mauro Carvalho Chehab 2020-04-30 18:04:12 +02:00 committed by David S. Miller
parent 4ba7bc9f2d
commit 6e94eaaa40
4 changed files with 39 additions and 22 deletions

View file

@ -90,6 +90,7 @@ Contents:
openvswitch openvswitch
operstates operstates
packet_mmap packet_mmap
phonet
.. only:: subproject and html .. only:: subproject and html

View file

@ -1076,7 +1076,7 @@ Miscellaneous bits
================== ==================
- Packet sockets work well together with Linux socket filters, thus you also - Packet sockets work well together with Linux socket filters, thus you also
might want to have a look at Documentation/networking/filter.txt might want to have a look at Documentation/networking/filter.rst
THANKS THANKS
====== ======

View file

@ -1,3 +1,7 @@
.. SPDX-License-Identifier: GPL-2.0
.. include:: <isonum.txt>
============================
Linux Phonet protocol family Linux Phonet protocol family
============================ ============================
@ -11,6 +15,7 @@ device attached to the modem. The modem takes care of routing.
Phonet packets can be exchanged through various hardware connections Phonet packets can be exchanged through various hardware connections
depending on the device, such as: depending on the device, such as:
- USB with the CDC Phonet interface, - USB with the CDC Phonet interface,
- infrared, - infrared,
- Bluetooth, - Bluetooth,
@ -21,7 +26,7 @@ depending on the device, such as:
Packets format Packets format
-------------- --------------
Phonet packets have a common header as follows: Phonet packets have a common header as follows::
struct phonethdr { struct phonethdr {
uint8_t pn_media; /* Media type (link-layer identifier) */ uint8_t pn_media; /* Media type (link-layer identifier) */
@ -72,7 +77,7 @@ only the (default) Linux FIFO qdisc should be used with them.
Network layer Network layer
------------- -------------
The Phonet socket address family maps the Phonet packet header: The Phonet socket address family maps the Phonet packet header::
struct sockaddr_pn { struct sockaddr_pn {
sa_family_t spn_family; /* AF_PHONET */ sa_family_t spn_family; /* AF_PHONET */
@ -94,6 +99,8 @@ protocol from the PF_PHONET family. Each socket is bound to one of the
2^10 object IDs available, and can send and receive packets with any 2^10 object IDs available, and can send and receive packets with any
other peer. other peer.
::
struct sockaddr_pn addr = { .spn_family = AF_PHONET, }; struct sockaddr_pn addr = { .spn_family = AF_PHONET, };
ssize_t len; ssize_t len;
socklen_t addrlen = sizeof(addr); socklen_t addrlen = sizeof(addr);
@ -116,7 +123,7 @@ Resource subscription
--------------------- ---------------------
A Phonet datagram socket can be subscribed to any number of 8-bits A Phonet datagram socket can be subscribed to any number of 8-bits
Phonet resources, as follow: Phonet resources, as follow::
uint32_t res = 0xXX; uint32_t res = 0xXX;
ioctl(fd, SIOCPNADDRESOURCE, &res); ioctl(fd, SIOCPNADDRESOURCE, &res);
@ -137,6 +144,8 @@ socket paradigm. The listening socket is bound to an unique free object
ID. Each listening socket can handle up to 255 simultaneous ID. Each listening socket can handle up to 255 simultaneous
connections, one per accept()'d socket. connections, one per accept()'d socket.
::
int lfd, cfd; int lfd, cfd;
lfd = socket(PF_PHONET, SOCK_SEQPACKET, PN_PROTO_PIPE); lfd = socket(PF_PHONET, SOCK_SEQPACKET, PN_PROTO_PIPE);
@ -161,7 +170,7 @@ Connections are traditionally established between two endpoints by a
As of Linux kernel version 2.6.39, it is also possible to connect As of Linux kernel version 2.6.39, it is also possible to connect
two endpoints directly, using connect() on the active side. This is two endpoints directly, using connect() on the active side. This is
intended to support the newer Nokia Wireless Modem API, as found in intended to support the newer Nokia Wireless Modem API, as found in
e.g. the Nokia Slim Modem in the ST-Ericsson U8500 platform: e.g. the Nokia Slim Modem in the ST-Ericsson U8500 platform::
struct sockaddr_spn spn; struct sockaddr_spn spn;
int fd; int fd;
@ -177,30 +186,35 @@ e.g. the Nokia Slim Modem in the ST-Ericsson U8500 platform:
close(fd); close(fd);
WARNING: .. Warning:
When polling a connected pipe socket for writability, there is an
intrinsic race condition whereby writability might be lost between the When polling a connected pipe socket for writability, there is an
polling and the writing system calls. In this case, the socket will intrinsic race condition whereby writability might be lost between the
block until write becomes possible again, unless non-blocking mode polling and the writing system calls. In this case, the socket will
is enabled. block until write becomes possible again, unless non-blocking mode
is enabled.
The pipe protocol provides two socket options at the SOL_PNPIPE level: The pipe protocol provides two socket options at the SOL_PNPIPE level:
PNPIPE_ENCAP accepts one integer value (int) of: PNPIPE_ENCAP accepts one integer value (int) of:
PNPIPE_ENCAP_NONE: The socket operates normally (default). PNPIPE_ENCAP_NONE:
The socket operates normally (default).
PNPIPE_ENCAP_IP: The socket is used as a backend for a virtual IP PNPIPE_ENCAP_IP:
The socket is used as a backend for a virtual IP
interface. This requires CAP_NET_ADMIN capability. GPRS data interface. This requires CAP_NET_ADMIN capability. GPRS data
support on Nokia modems can use this. Note that the socket cannot support on Nokia modems can use this. Note that the socket cannot
be reliably poll()'d or read() from while in this mode. be reliably poll()'d or read() from while in this mode.
PNPIPE_IFINDEX is a read-only integer value. It contains the PNPIPE_IFINDEX
is a read-only integer value. It contains the
interface index of the network interface created by PNPIPE_ENCAP, interface index of the network interface created by PNPIPE_ENCAP,
or zero if encapsulation is off. or zero if encapsulation is off.
PNPIPE_HANDLE is a read-only integer value. It contains the underlying PNPIPE_HANDLE
is a read-only integer value. It contains the underlying
identifier ("pipe handle") of the pipe. This is only defined for identifier ("pipe handle") of the pipe. This is only defined for
socket descriptors that are already connected or being connected. socket descriptors that are already connected or being connected.
@ -209,6 +223,8 @@ Authors
------- -------
Linux Phonet was initially written by Sakari Ailus. Linux Phonet was initially written by Sakari Ailus.
Other contributors include Mikä Liljeberg, Andras Domokos, Other contributors include Mikä Liljeberg, Andras Domokos,
Carlos Chinea and Rémi Denis-Courmont. Carlos Chinea and Rémi Denis-Courmont.
Copyright (C) 2008 Nokia Corporation.
Copyright |copy| 2008 Nokia Corporation.

View file

@ -13262,7 +13262,7 @@ F: drivers/input/joystick/pxrc.c
PHONET PROTOCOL PHONET PROTOCOL
M: Remi Denis-Courmont <courmisch@gmail.com> M: Remi Denis-Courmont <courmisch@gmail.com>
S: Supported S: Supported
F: Documentation/networking/phonet.txt F: Documentation/networking/phonet.rst
F: include/linux/phonet.h F: include/linux/phonet.h
F: include/net/phonet/ F: include/net/phonet/
F: include/uapi/linux/phonet.h F: include/uapi/linux/phonet.h