PVC devices are virtual devices in this driver stacked on top of the
actual HDLC device. They are the devices normal users would use.
PVC devices have two types: normal PVC devices and Ethernet-emulating
PVC devices.
When transmitting data with PVC devices, the ndo_start_xmit function
will prepend a header of 4 or 10 bytes. Currently this driver requests
this headroom to be reserved for normal PVC devices by setting their
hard_header_len to 10. However, this does not work when these devices
are used with AF_PACKET/RAW sockets. Also, this driver does not request
this headroom for Ethernet-emulating PVC devices (but deals with this
problem by reallocating the skb when needed, which is not optimal).
This patch replaces hard_header_len with needed_headroom, and set
needed_headroom for Ethernet-emulating PVC devices, too. This makes
the driver to request headroom for all PVC devices in all cases.
Cc: Krzysztof Halasa <khc@pm.waw.pl>
Cc: Martin Schiller <ms@dev.tdt.de>
Signed-off-by: Xie He <redacted>
---
Change from v1:
English language fix for the commit message.
Changed "Ethernet-emulated" to "Ethernet-emulating" because the device
is emulating an Ethernet device, rather than being emulated by an
Ethernet device.
I'm sorry for my poor English.
---
drivers/net/wan/hdlc_fr.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
@@ -1093,6 +1093,7 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type)dev->mtu=HDLC_MAX_MTU;dev->min_mtu=68;dev->max_mtu=HDLC_MAX_MTU;+dev->needed_headroom=10;dev->priv_flags|=IFF_NO_QUEUE;dev->ml_priv=pvc;
From: Jakub Kicinski <kuba@kernel.org> Date: 2020-09-04 22:14:47
On Wed, 2 Sep 2020 17:06:58 -0700 Xie He wrote:
PVC devices are virtual devices in this driver stacked on top of the
actual HDLC device. They are the devices normal users would use.
PVC devices have two types: normal PVC devices and Ethernet-emulating
PVC devices.
When transmitting data with PVC devices, the ndo_start_xmit function
will prepend a header of 4 or 10 bytes. Currently this driver requests
this headroom to be reserved for normal PVC devices by setting their
hard_header_len to 10. However, this does not work when these devices
are used with AF_PACKET/RAW sockets. Also, this driver does not request
this headroom for Ethernet-emulating PVC devices (but deals with this
problem by reallocating the skb when needed, which is not optimal).
This patch replaces hard_header_len with needed_headroom, and set
needed_headroom for Ethernet-emulating PVC devices, too. This makes
the driver to request headroom for all PVC devices in all cases.
Since this is a tunnel protocol on top of HDLC interfaces, and
hdlc_setup_dev() sets dev->hard_header_len = 16; should we actually
set the needed_headroom to 10 + 16 = 26? I'm not clear on where/if
hdlc devices actually prepend 16 bytes of header, though.
CC: Willem as he was reviewing your similar patch recently.
Thank you for your email, Jakub!
On Fri, Sep 4, 2020 at 3:14 PM Jakub Kicinski [off-list ref] wrote:
Since this is a tunnel protocol on top of HDLC interfaces, and
hdlc_setup_dev() sets dev->hard_header_len = 16; should we actually
set the needed_headroom to 10 + 16 = 26? I'm not clear on where/if
hdlc devices actually prepend 16 bytes of header, though.
The HDLC device is not actually prepending any header when it is used
with this driver. When the PVC device has prepended its header and
handed over the skb to the HDLC device, the HDLC device just hands it
over to the hardware driver for transmission without prepending any
header.
If we grep "header_ops" and "skb_push" in "hdlc.c" and "hdlc_fr.c", we
can see there is no "header_ops" implemented in these two files and
all "skb_push" happen in the PVC device in hdlc_fr.c.
For this reason, I have previously submitted a patch to change the
value of hard_header_len of the HDLC device from 16 to 0, because it
is not actually used.
See:
2b7bcd967a0f (drivers/net/wan/hdlc: Change the default of hard_header_len to 0)
Is there a need to set this to 0? Will it not be zero after allocation?
Oh. I understand your point. Theoretically we don't need to set it to
0 because it already has the default value of 0. I'm setting it to 0
only because I want to tell future developers that this value is
intentionally set to 0, and it is not carelessly missed out.
On Fri, Sep 4, 2020 at 6:28 PM Xie He [off-list ref] wrote:
The HDLC device is not actually prepending any header when it is used
with this driver. When the PVC device has prepended its header and
handed over the skb to the HDLC device, the HDLC device just hands it
over to the hardware driver for transmission without prepending any
header.
If we grep "header_ops" and "skb_push" in "hdlc.c" and "hdlc_fr.c", we
can see there is no "header_ops" implemented in these two files and
all "skb_push" happen in the PVC device in hdlc_fr.c.
I want to provide a little more information about the flow after an
HDLC device's ndo_start_xmit is called.
An HDLC hardware driver's ndo_start_xmit is required to point to
hdlc_start_xmit in hdlc.c. When a HDLC device receives a call to its
ndo_start_xmit, hdlc_start_xmit will check if the protocol driver has
provided a xmit function. If it has provided this function,
hdlc_start_xmit will call it to start transmission. If it has not,
hdlc_start_xmit will directly call the hardware driver's function to
start transmission. This driver (hdlc_fr) has not provided a xmit
function in its hdlc_proto struct, so hdlc_start_xmit will directly
call the hardware driver's function to transmit.
So no header will be prepended after ndo_start_xmit is called.
There would not be any header prepended before ndo_start_xmit is
called, either, because there is no header_ops implemented in either
hdlc.c or hdlc_fr.c.
On Fri, Sep 4, 2020 at 6:28 PM Xie He [off-list ref] wrote:
Thank you for your email, Jakub!
On Fri, Sep 4, 2020 at 3:14 PM Jakub Kicinski [off-list ref] wrote:
quoted
Since this is a tunnel protocol on top of HDLC interfaces, and
hdlc_setup_dev() sets dev->hard_header_len = 16; should we actually
set the needed_headroom to 10 + 16 = 26? I'm not clear on where/if
hdlc devices actually prepend 16 bytes of header, though.
The HDLC device is not actually prepending any header when it is used
with this driver. When the PVC device has prepended its header and
handed over the skb to the HDLC device, the HDLC device just hands it
over to the hardware driver for transmission without prepending any
header.
If we grep "header_ops" and "skb_push" in "hdlc.c" and "hdlc_fr.c", we
can see there is no "header_ops" implemented in these two files and
all "skb_push" happen in the PVC device in hdlc_fr.c.
For this reason, I have previously submitted a patch to change the
value of hard_header_len of the HDLC device from 16 to 0, because it
is not actually used.
See:
2b7bcd967a0f (drivers/net/wan/hdlc: Change the default of hard_header_len to 0)
Is there a need to set this to 0? Will it not be zero after allocation?
Oh. I understand your point. Theoretically we don't need to set it to
0 because it already has the default value of 0. I'm setting it to 0
only because I want to tell future developers that this value is
intentionally set to 0, and it is not carelessly missed out.
From: Jakub Kicinski <kuba@kernel.org> Date: 2020-09-05 04:36:27
On Fri, 4 Sep 2020 18:57:27 -0700 Xie He wrote:
On Fri, Sep 4, 2020 at 6:28 PM Xie He [off-list ref] wrote:
quoted
The HDLC device is not actually prepending any header when it is used
with this driver. When the PVC device has prepended its header and
handed over the skb to the HDLC device, the HDLC device just hands it
over to the hardware driver for transmission without prepending any
header.
If we grep "header_ops" and "skb_push" in "hdlc.c" and "hdlc_fr.c", we
can see there is no "header_ops" implemented in these two files and
all "skb_push" happen in the PVC device in hdlc_fr.c.
I want to provide a little more information about the flow after an
HDLC device's ndo_start_xmit is called.
An HDLC hardware driver's ndo_start_xmit is required to point to
hdlc_start_xmit in hdlc.c. When a HDLC device receives a call to its
ndo_start_xmit, hdlc_start_xmit will check if the protocol driver has
provided a xmit function. If it has provided this function,
hdlc_start_xmit will call it to start transmission. If it has not,
hdlc_start_xmit will directly call the hardware driver's function to
start transmission. This driver (hdlc_fr) has not provided a xmit
function in its hdlc_proto struct, so hdlc_start_xmit will directly
call the hardware driver's function to transmit.
So no header will be prepended after ndo_start_xmit is called.
There would not be any header prepended before ndo_start_xmit is
called, either, because there is no header_ops implemented in either
hdlc.c or hdlc_fr.c.
Thank you for the detailed explanation.
On Fri, Sep 4, 2020 at 6:28 PM Xie He [off-list ref] wrote:
quoted
Thank you for your email, Jakub!
On Fri, Sep 4, 2020 at 3:14 PM Jakub Kicinski [off-list ref] wrote:
quoted
Since this is a tunnel protocol on top of HDLC interfaces, and
hdlc_setup_dev() sets dev->hard_header_len = 16; should we actually
set the needed_headroom to 10 + 16 = 26? I'm not clear on where/if
hdlc devices actually prepend 16 bytes of header, though.
The HDLC device is not actually prepending any header when it is used
with this driver. When the PVC device has prepended its header and
handed over the skb to the HDLC device, the HDLC device just hands it
over to the hardware driver for transmission without prepending any
header.
If we grep "header_ops" and "skb_push" in "hdlc.c" and "hdlc_fr.c", we
can see there is no "header_ops" implemented in these two files and
all "skb_push" happen in the PVC device in hdlc_fr.c.
For this reason, I have previously submitted a patch to change the
value of hard_header_len of the HDLC device from 16 to 0, because it
is not actually used.
See:
2b7bcd967a0f (drivers/net/wan/hdlc: Change the default of hard_header_len to 0)
Ah, sorry.. the tree I was looking at did not have this commit.
Is there a need to set this to 0? Will it not be zero after allocation?
Oh. I understand your point. Theoretically we don't need to set it to
0 because it already has the default value of 0. I'm setting it to 0
only because I want to tell future developers that this value is
intentionally set to 0, and it is not carelessly missed out.