Skip to content

Commit

Permalink
Merge branch 'net-next-2024-12-22--00-00' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Dec 22, 2024
2 parents ce2660e + 6cd9d6d commit 28180f4
Show file tree
Hide file tree
Showing 854 changed files with 29,169 additions and 9,123 deletions.
118 changes: 113 additions & 5 deletions Documentation/core-api/packing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,119 @@ Intended use

Drivers that opt to use this API first need to identify which of the above 3
quirk combinations (for a total of 8) match what the hardware documentation
describes. Then they should wrap the packing() function, creating a new
xxx_packing() that calls it using the proper QUIRK_* one-hot bits set.
describes.

There are 3 supported usage patterns, detailed below.

packing()
^^^^^^^^^

This API function is deprecated.

The packing() function returns an int-encoded error code, which protects the
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.
during runtime, therefore it is reasonable to wrap packing() into a custom
function which returns void and swallows those errors. Optionally it can
dump stack or print the error description.

.. code-block:: c
void my_packing(void *buf, u64 *val, int startbit, int endbit,
size_t len, enum packing_op op)
{
int err;
/* Adjust quirks accordingly */
err = packing(buf, val, startbit, endbit, len, op, QUIRK_LSW32_IS_FIRST);
if (likely(!err))
return;
if (err == -EINVAL) {
pr_err("Start bit (%d) expected to be larger than end (%d)\n",
startbit, endbit);
} else if (err == -ERANGE) {
if ((startbit - endbit + 1) > 64)
pr_err("Field %d-%d too large for 64 bits!\n",
startbit, endbit);
else
pr_err("Cannot store %llx inside bits %d-%d (would truncate)\n",
*val, startbit, endbit);
}
dump_stack();
}
pack() and unpack()
^^^^^^^^^^^^^^^^^^^

These are const-correct variants of packing(), and eliminate the last "enum
packing_op op" argument.

Calling pack(...) is equivalent, and preferred, to calling packing(..., PACK).

Calling unpack(...) is equivalent, and preferred, to calling packing(..., UNPACK).

pack_fields() and unpack_fields()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The library exposes optimized functions for the scenario where there are many
fields represented in a buffer, and it encourages consumer drivers to avoid
repetitive calls to pack() and unpack() for each field, but instead use
pack_fields() and unpack_fields(), which reduces the code footprint.

These APIs use field definitions in arrays of ``struct packed_field_u8`` or
``struct packed_field_u16``, allowing consumer drivers to minimize the size
of these arrays according to their custom requirements.

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

An additional benefit over pack() and unpack() is that sanity checks on the
field definitions are handled at compile time with ``BUILD_BUG_ON`` rather
than only when the offending code is executed. These functions return void and
wrapping them to handle unexpected errors is not necessary.

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
/* Ordering inside the unpacked structure is flexible and can be different
* from the packed buffer. Here, it is optimized to reduce padding.
*/
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_u8 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);
}
12 changes: 12 additions & 0 deletions Documentation/devicetree/bindings/net/ethernet-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ properties:
nvmem-cell-names:
const: mac-address

nvmem-mac-minor-offset:
$ref: /schemas/types.yaml#/definitions/uint32
minimum: 1
maximum: 255
description:
When a MAC address for a device with multiple ethernet interface
is stored in non-volatile memory, the address is often offsetted
for different interfaces by increasing the lowermost byte for each
interface subsequent to the first in order to save space in NVMEM.
This property can be used to add that offset when several
interfaces refer to the same NVMEM cell.

phy-connection-type:
description:
Specifies interface type between the Ethernet device and a physical
Expand Down
105 changes: 105 additions & 0 deletions Documentation/devicetree/bindings/net/nxp,s32-dwmac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
# Copyright 2021-2024 NXP
%YAML 1.2
---
$id: http://devicetree.org/schemas/net/nxp,s32-dwmac.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: NXP S32G2xx/S32G3xx/S32R45 GMAC ethernet controller

maintainers:
- Jan Petrous (OSS) <jan.petrous@oss.nxp.com>

description:
This device is a Synopsys DWC IP, integrated on NXP S32G/R SoCs.
The SoC series S32G2xx and S32G3xx feature one DWMAC instance,
the SoC S32R45 has two instances. The devices can use RGMII/RMII/MII
interface over Pinctrl device or the output can be routed
to the embedded SerDes for SGMII connectivity.

properties:
compatible:
oneOf:
- const: nxp,s32g2-dwmac
- items:
- enum:
- nxp,s32g3-dwmac
- nxp,s32r45-dwmac
- const: nxp,s32g2-dwmac

reg:
items:
- description: Main GMAC registers
- description: GMAC PHY mode control register

interrupts:
maxItems: 1

interrupt-names:
const: macirq

clocks:
items:
- description: Main GMAC clock
- description: Transmit clock
- description: Receive clock
- description: PTP reference clock

clock-names:
items:
- const: stmmaceth
- const: tx
- const: rx
- const: ptp_ref

required:
- clocks
- clock-names

allOf:
- $ref: snps,dwmac.yaml#

unevaluatedProperties: false

examples:
- |
#include <dt-bindings/interrupt-controller/arm-gic.h>
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/phy/phy.h>
bus {
#address-cells = <2>;
#size-cells = <2>;
ethernet@4033c000 {
compatible = "nxp,s32g2-dwmac";
reg = <0x0 0x4033c000 0x0 0x2000>, /* gmac IP */
<0x0 0x4007c004 0x0 0x4>; /* GMAC_0_CTRL_STS */
interrupt-parent = <&gic>;
interrupts = <GIC_SPI 57 IRQ_TYPE_LEVEL_HIGH>;
interrupt-names = "macirq";
snps,mtl-rx-config = <&mtl_rx_setup>;
snps,mtl-tx-config = <&mtl_tx_setup>;
clocks = <&clks 24>, <&clks 17>, <&clks 16>, <&clks 15>;
clock-names = "stmmaceth", "tx", "rx", "ptp_ref";
phy-mode = "rgmii-id";
phy-handle = <&phy0>;
mtl_rx_setup: rx-queues-config {
snps,rx-queues-to-use = <5>;
};
mtl_tx_setup: tx-queues-config {
snps,tx-queues-to-use = <5>;
};
mdio {
#address-cells = <1>;
#size-cells = <0>;
compatible = "snps,dwmac-mdio";
phy0: ethernet-phy@0 {
reg = <0>;
};
};
};
};
1 change: 1 addition & 0 deletions Documentation/devicetree/bindings/net/snps,dwmac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ properties:
- ingenic,x2000-mac
- loongson,ls2k-dwmac
- loongson,ls7a-dwmac
- nxp,s32g2-dwmac
- qcom,qcs404-ethqos
- qcom,sa8775p-ethqos
- qcom,sc8280xp-ethqos
Expand Down
27 changes: 27 additions & 0 deletions Documentation/devicetree/bindings/net/ti,dp83822.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,32 @@ properties:
- master
- slave

ti,gpio2-clk-out:
description: |
DP83822 PHY only.
The GPIO2 pin on the DP83822 can be configured as clock output. When
omitted, the PHY's default will be left as is.
- 'mac-if': In MII mode the clock frequency is 25-MHz, in RMII Mode the
clock frequency is 50-MHz and in RGMII Mode the clock frequency is
25-MHz.
- 'xi': XI clock(pass-through clock from XI pin).
- 'int-ref': Internal reference clock 25-MHz.
- 'rmii-master-mode-ref': RMII master mode reference clock 50-MHz. RMII
master mode reference clock is identical to MAC IF clock in RMII master
mode.
- 'free-running': Free running clock 125-MHz.
- 'recovered': Recovered clock is a 125-MHz recovered clock from a
connected link partner.
$ref: /schemas/types.yaml#/definitions/string
enum:
- mac-if
- xi
- int-ref
- rmii-master-mode-ref
- free-running
- recovered

required:
- reg

Expand All @@ -110,6 +136,7 @@ examples:
reg = <0>;
rx-internal-delay-ps = <1>;
tx-internal-delay-ps = <1>;
ti,gpio2-clk-out = "xi";
};
};
Expand Down
3 changes: 3 additions & 0 deletions Documentation/netlink/genetlink-c.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ properties:
name-prefix:
description: For enum the prefix of the values, optional.
type: string
enum-cnt-name:
description: Name of the render-max counter enum entry.
type: string
# End genetlink-c

attribute-sets:
Expand Down
3 changes: 3 additions & 0 deletions Documentation/netlink/genetlink-legacy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ properties:
name-prefix:
description: For enum the prefix of the values, optional.
type: string
enum-cnt-name:
description: Name of the render-max counter enum entry.
type: string
# End genetlink-c
# Start genetlink-legacy
members:
Expand Down
2 changes: 1 addition & 1 deletion Documentation/netlink/netlink-raw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ properties:
type: &attr-type
description: The netlink attribute type
enum: [ unused, pad, flag, binary, bitfield32,
u8, u16, u32, u64, s8, s16, s32, s64,
uint, sint, u8, u16, u32, u64, s8, s16, s32, s64,
string, nest, indexed-array, nest-type-value,
sub-message ]
doc:
Expand Down
Loading

0 comments on commit 28180f4

Please sign in to comment.