Skip to content

Commit

Permalink
Merge branch 'net-next-2024-12-03--09-00' into HEAD
Browse files Browse the repository at this point in the history
# Conflicts:
#	drivers/ptp/ptp_dte.c
#	drivers/ptp/ptp_ines.c
  • Loading branch information
Your Name committed Dec 3, 2024
2 parents 525b4ba + 3744239 commit 4b22a04
Show file tree
Hide file tree
Showing 112 changed files with 4,478 additions and 940 deletions.
58 changes: 58 additions & 0 deletions Documentation/core-api/packing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,61 @@ programmer against incorrect API use. The errors are not expected to occur
during runtime, therefore it is reasonable for xxx_packing() to return void
and simply swallow those errors. Optionally it can dump stack or print the
error description.

The pack_fields() and unpack_fields() macros automatically select the
appropriate function at compile time based on the type of the fields array
passed in.

Packed Fields
-------------

Drivers are encouraged to use the ``pack_fields()`` and ``unpack_fields()``
APIs over using ``pack()``, ``unpack()``, or ``packing()``.

These APIs use field definitions in arrays of ``struct packed_field_s`` or
``struct packed_field_m`` stored as ``.rodata``. This significantly reduces
the code footprint required to pack or unpack many fields. In addition,
sanity checks on the field definitions are handled at compile time with
``BUILD_BUG_ON`` rather than only when the offending code is executed.

It is recommended, but not required, that you wrap your packed buffer into a
structured type with a fixed size. This generally makes it easier for the
compiler to enforce that the correct size buffer is used.

Here is an example of how to use the fields APIs:

.. code-block:: c
struct data {
u64 field3;
u32 field4;
u16 field1;
u8 field2;
};
#define SIZE 13
typdef struct __packed { u8 buf[SIZE]; } packed_buf_t;
static const struct packed_field_s fields[] = {
PACKED_FIELD(100, 90, struct data, field1),
PACKED_FIELD(90, 87, struct data, field2),
PACKED_FIELD(86, 30, struct data, field3),
PACKED_FIELD(29, 0, struct data, field4),
};
void unpack_your_data(const packed_buf_t *buf, struct data *unpacked)
{
BUILD_BUG_ON(sizeof(*buf) != SIZE;
unpack_fields(buf, sizeof(*buf), unpacked, fields,
QUIRK_LITTLE_ENDIAN);
}
void pack_your_data(const struct data *unpacked, packed_buf_t *buf)
{
BUILD_BUG_ON(sizeof(*buf) != SIZE;
pack_fields(buf, sizeof(*buf), unpacked, fields,
QUIRK_LITTLE_ENDIAN);
}
11 changes: 6 additions & 5 deletions Documentation/networking/bareudp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ Bare UDP Tunnelling Module Documentation

There are various L3 encapsulation standards using UDP being discussed to
leverage the UDP based load balancing capability of different networks.
MPLSoUDP (__ https://tools.ietf.org/html/rfc7510) is one among them.
MPLSoUDP (https://tools.ietf.org/html/rfc7510) is one among them.

The Bareudp tunnel module provides a generic L3 encapsulation support for
tunnelling different L3 protocols like MPLS, IP, NSH etc. inside a UDP tunnel.

Special Handling
----------------

The bareudp device supports special handling for MPLS & IP as they can have
multiple ethertypes.
MPLS procotcol can have ethertypes ETH_P_MPLS_UC (unicast) & ETH_P_MPLS_MC (multicast).
The MPLS protocol can have ethertypes ETH_P_MPLS_UC (unicast) & ETH_P_MPLS_MC (multicast).
IP protocol can have ethertypes ETH_P_IP (v4) & ETH_P_IPV6 (v6).
This special handling can be enabled only for ethertypes ETH_P_IP & ETH_P_MPLS_UC
with a flag called multiproto mode.
Expand Down Expand Up @@ -52,7 +53,7 @@ be enabled explicitly with the "multiproto" flag.
3) Device Usage

The bareudp device could be used along with OVS or flower filter in TC.
The OVS or TC flower layer must set the tunnel information in SKB dst field before
sending packet buffer to the bareudp device for transmission. On reception the
bareudp device extracts and stores the tunnel information in SKB dst field before
The OVS or TC flower layer must set the tunnel information in the SKB dst field before
sending the packet buffer to the bareudp device for transmission. On reception, the
bareUDP device extracts and stores the tunnel information in the SKB dst field before
passing the packet buffer to the network stack.
5 changes: 3 additions & 2 deletions Documentation/networking/netconsole.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ To remove a target::

The interface exposes these parameters of a netconsole target to userspace:

============== ================================= ============
=============== ================================= ============
enabled Is this target currently enabled? (read-write)
extended Extended mode enabled (read-write)
release Prepend kernel release to message (read-write)
Expand All @@ -135,7 +135,8 @@ The interface exposes these parameters of a netconsole target to userspace:
remote_ip Remote agent's IP address (read-write)
local_mac Local interface's MAC address (read-only)
remote_mac Remote agent's MAC address (read-write)
============== ================================= ============
transmit_errors Number of packet send errors (read-only)
=============== ================================= ============

The "enabled" attribute is also used to control whether the parameters of
a target can be updated or not -- you can modify the parameters of only
Expand Down
3 changes: 3 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -16267,6 +16267,7 @@ F: Documentation/devicetree/bindings/net/
F: Documentation/networking/net_cachelines/net_device.rst
F: drivers/connector/
F: drivers/net/
F: drivers/ptp/
F: include/dt-bindings/net/
F: include/linux/cn_proc.h
F: include/linux/etherdevice.h
Expand Down Expand Up @@ -17633,8 +17634,10 @@ L: [email protected]
S: Supported
F: Documentation/core-api/packing.rst
F: include/linux/packing.h
F: include/linux/packing_types.h
F: lib/packing.c
F: lib/packing_test.c
F: scripts/gen_packed_field_checks.c

PADATA PARALLEL EXECUTION MECHANISM
M: Steffen Klassert <[email protected]>
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,10 @@ PHONY += scripts_unifdef
scripts_unifdef: scripts_basic
$(Q)$(MAKE) $(build)=scripts scripts/unifdef

PHONY += scripts_gen_packed_field_checks
scripts_gen_packed_field_checks: scripts_basic
$(Q)$(MAKE) $(build)=scripts scripts/gen_packed_field_checks

# ---------------------------------------------------------------------------
# Install

Expand Down
26 changes: 17 additions & 9 deletions drivers/net/can/c_can/c_can_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1014,49 +1014,57 @@ static int c_can_handle_bus_err(struct net_device *dev,

/* propagate the error condition to the CAN stack */
skb = alloc_can_err_skb(dev, &cf);
if (unlikely(!skb))
return 0;

/* check for 'last error code' which tells us the
* type of the last error to occur on the CAN bus
*/
cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
if (likely(skb))
cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;

switch (lec_type) {
case LEC_STUFF_ERROR:
netdev_dbg(dev, "stuff error\n");
cf->data[2] |= CAN_ERR_PROT_STUFF;
if (likely(skb))
cf->data[2] |= CAN_ERR_PROT_STUFF;
stats->rx_errors++;
break;
case LEC_FORM_ERROR:
netdev_dbg(dev, "form error\n");
cf->data[2] |= CAN_ERR_PROT_FORM;
if (likely(skb))
cf->data[2] |= CAN_ERR_PROT_FORM;
stats->rx_errors++;
break;
case LEC_ACK_ERROR:
netdev_dbg(dev, "ack error\n");
cf->data[3] = CAN_ERR_PROT_LOC_ACK;
if (likely(skb))
cf->data[3] = CAN_ERR_PROT_LOC_ACK;
stats->tx_errors++;
break;
case LEC_BIT1_ERROR:
netdev_dbg(dev, "bit1 error\n");
cf->data[2] |= CAN_ERR_PROT_BIT1;
if (likely(skb))
cf->data[2] |= CAN_ERR_PROT_BIT1;
stats->tx_errors++;
break;
case LEC_BIT0_ERROR:
netdev_dbg(dev, "bit0 error\n");
cf->data[2] |= CAN_ERR_PROT_BIT0;
if (likely(skb))
cf->data[2] |= CAN_ERR_PROT_BIT0;
stats->tx_errors++;
break;
case LEC_CRC_ERROR:
netdev_dbg(dev, "CRC error\n");
cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
if (likely(skb))
cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
stats->rx_errors++;
break;
default:
break;
}

if (unlikely(!skb))
return 0;

netif_receive_skb(skb);
return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/can/dev/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ static int can_set_termination(struct net_device *ndev, u16 term)
else
set = 0;

gpiod_set_value(priv->termination_gpio, set);
gpiod_set_value_cansleep(priv->termination_gpio, set);

return 0;
}
Expand Down
58 changes: 40 additions & 18 deletions drivers/net/can/ifi_canfd/ifi_canfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,43 +390,65 @@ static int ifi_canfd_handle_lec_err(struct net_device *ndev)
return 0;

priv->can.can_stats.bus_error++;
stats->rx_errors++;

/* Propagate the error condition to the CAN stack. */
skb = alloc_can_err_skb(ndev, &cf);
if (unlikely(!skb))
return 0;

/* Read the error counter register and check for new errors. */
cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
if (likely(skb))
cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;

if (errctr & IFI_CANFD_ERROR_CTR_OVERLOAD_FIRST)
cf->data[2] |= CAN_ERR_PROT_OVERLOAD;
if (errctr & IFI_CANFD_ERROR_CTR_OVERLOAD_FIRST) {
stats->rx_errors++;
if (likely(skb))
cf->data[2] |= CAN_ERR_PROT_OVERLOAD;
}

if (errctr & IFI_CANFD_ERROR_CTR_ACK_ERROR_FIRST)
cf->data[3] = CAN_ERR_PROT_LOC_ACK;
if (errctr & IFI_CANFD_ERROR_CTR_ACK_ERROR_FIRST) {
stats->tx_errors++;
if (likely(skb))
cf->data[3] = CAN_ERR_PROT_LOC_ACK;
}

if (errctr & IFI_CANFD_ERROR_CTR_BIT0_ERROR_FIRST)
cf->data[2] |= CAN_ERR_PROT_BIT0;
if (errctr & IFI_CANFD_ERROR_CTR_BIT0_ERROR_FIRST) {
stats->tx_errors++;
if (likely(skb))
cf->data[2] |= CAN_ERR_PROT_BIT0;
}

if (errctr & IFI_CANFD_ERROR_CTR_BIT1_ERROR_FIRST)
cf->data[2] |= CAN_ERR_PROT_BIT1;
if (errctr & IFI_CANFD_ERROR_CTR_BIT1_ERROR_FIRST) {
stats->tx_errors++;
if (likely(skb))
cf->data[2] |= CAN_ERR_PROT_BIT1;
}

if (errctr & IFI_CANFD_ERROR_CTR_STUFF_ERROR_FIRST)
cf->data[2] |= CAN_ERR_PROT_STUFF;
if (errctr & IFI_CANFD_ERROR_CTR_STUFF_ERROR_FIRST) {
stats->rx_errors++;
if (likely(skb))
cf->data[2] |= CAN_ERR_PROT_STUFF;
}

if (errctr & IFI_CANFD_ERROR_CTR_CRC_ERROR_FIRST)
cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
if (errctr & IFI_CANFD_ERROR_CTR_CRC_ERROR_FIRST) {
stats->rx_errors++;
if (likely(skb))
cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
}

if (errctr & IFI_CANFD_ERROR_CTR_FORM_ERROR_FIRST)
cf->data[2] |= CAN_ERR_PROT_FORM;
if (errctr & IFI_CANFD_ERROR_CTR_FORM_ERROR_FIRST) {
stats->rx_errors++;
if (likely(skb))
cf->data[2] |= CAN_ERR_PROT_FORM;
}

/* Reset the error counter, ack the IRQ and re-enable the counter. */
writel(IFI_CANFD_ERROR_CTR_ER_RESET, priv->base + IFI_CANFD_ERROR_CTR);
writel(IFI_CANFD_INTERRUPT_ERROR_COUNTER,
priv->base + IFI_CANFD_INTERRUPT);
writel(IFI_CANFD_ERROR_CTR_ER_ENABLE, priv->base + IFI_CANFD_ERROR_CTR);

if (unlikely(!skb))
return 0;

netif_receive_skb(skb);

return 1;
Expand Down
33 changes: 23 additions & 10 deletions drivers/net/can/m_can/m_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,47 +695,60 @@ static int m_can_handle_lec_err(struct net_device *dev,
u32 timestamp = 0;

cdev->can.can_stats.bus_error++;
stats->rx_errors++;

/* propagate the error condition to the CAN stack */
skb = alloc_can_err_skb(dev, &cf);
if (unlikely(!skb))
return 0;

/* check for 'last error code' which tells us the
* type of the last error to occur on the CAN bus
*/
cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
if (likely(skb))
cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;

switch (lec_type) {
case LEC_STUFF_ERROR:
netdev_dbg(dev, "stuff error\n");
cf->data[2] |= CAN_ERR_PROT_STUFF;
stats->rx_errors++;
if (likely(skb))
cf->data[2] |= CAN_ERR_PROT_STUFF;
break;
case LEC_FORM_ERROR:
netdev_dbg(dev, "form error\n");
cf->data[2] |= CAN_ERR_PROT_FORM;
stats->rx_errors++;
if (likely(skb))
cf->data[2] |= CAN_ERR_PROT_FORM;
break;
case LEC_ACK_ERROR:
netdev_dbg(dev, "ack error\n");
cf->data[3] = CAN_ERR_PROT_LOC_ACK;
stats->tx_errors++;
if (likely(skb))
cf->data[3] = CAN_ERR_PROT_LOC_ACK;
break;
case LEC_BIT1_ERROR:
netdev_dbg(dev, "bit1 error\n");
cf->data[2] |= CAN_ERR_PROT_BIT1;
stats->tx_errors++;
if (likely(skb))
cf->data[2] |= CAN_ERR_PROT_BIT1;
break;
case LEC_BIT0_ERROR:
netdev_dbg(dev, "bit0 error\n");
cf->data[2] |= CAN_ERR_PROT_BIT0;
stats->tx_errors++;
if (likely(skb))
cf->data[2] |= CAN_ERR_PROT_BIT0;
break;
case LEC_CRC_ERROR:
netdev_dbg(dev, "CRC error\n");
cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
stats->rx_errors++;
if (likely(skb))
cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
break;
default:
break;
}

if (unlikely(!skb))
return 0;

if (cdev->is_peripheral)
timestamp = m_can_get_timestamp(cdev);

Expand Down
Loading

0 comments on commit 4b22a04

Please sign in to comment.