요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
.. include:: <isonum.txt>
=======================
DPAA2 MAC / PHY support
=======================
:Copyright: |copy| 2019 NXP
Overview
--------
The DPAA2 MAC / PHY support consists of a set of APIs that help DPAA2 network
drivers (dpaa2-eth, dpaa2-ethsw) interact with the PHY library.
DPAA2 Software Architecture
---------------------------
Among other DPAA2 objects, the fsl-mc bus exports DPNI objects (abstracting a
network interface) and DPMAC objects (abstracting a MAC). The dpaa2-eth driver
probes on the DPNI object and connects to and configures a DPMAC object with
the help of phylink.
Data connections may be established between a DPNI and a DPMAC, or between two
DPNIs. Depending on the connection type, the netif_carrier_[on/off] is handled
directly by the dpaa2-eth driver or by phylink.
.. code-block:: none
Sources of abstracted link state information presented by the MC firmware
+--------------------------------------+
+------------+ +---------+ | xgmac_mdio |
| net_device | | phylink |--| +-----+ +-----+ +-----+ +-----+ |
+------------+ +---------+ | | PHY | | PHY | | PHY | | PHY | |
| | | +-----+ +-----+ +-----+ +-----+ |
+------------------------------------+ | External MDIO bus |
| dpaa2-eth | +--------------------------------------+
+------------------------------------+
| | Linux
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | MC firmware
| /| V
+----------+ / | +----------+
| | / | | |
| | | | | |
| DPNI |<------| |<------| DPMAC |
| | | | | |
| | \ |<---+ | |
+----------+ \ | | +----------+
\| |
|
+--------------------------------------+
| MC firmware polling MAC PCS for link |
| +-----+ +-----+ +-----+ +-----+ |
| | PCS | | PCS | | PCS | | PCS | |
| +-----+ +-----+ +-----+ +-----+ |
| Internal MDIO bus |
+--------------------------------------+
Depending on an MC firmware configuration setting, each MAC may be in one of two modes:
- DPMAC_LINK_TYPE_FIXED: the link state management is handled exclusively by
the MC firmware by polling the MAC PCS. Without the need to register a
phylink instance, the dpaa2-eth driver will not bind to the connected dpmac
object at all.
- DPMAC_LINK_TYPE_PHY: The MC firmware is left waiting for link state update
events, but those are in fact passed strictly between the dpaa2-mac (based on
phylink) and its attached net_device driver (dpaa2-eth, dpaa2-ethsw),
effectively bypassing the firmware.
Implementation
--------------
At probe time or when a DPNI's endpoint is dynamically changed, the dpaa2-eth
is responsible to find out if the peer object is a DPMAC and if this is the
case, to integrate it with PHYLINK using the dpaa2_mac_connect() API, which
will do the following:
- look up the device tree for PHYLINK-compatible of binding (phy-handle)
- will create a PHYLINK instance associated with the received net_device
- connect to the PHY using phylink_of_phy_connect()
The following phylink_mac_ops callback are implemented:
- .validate() will populate the supported linkmodes with the MAC capabilities
only when the phy_interface_t is RGMII_* (at the moment, this is the only
link type supported by the driver).
- .mac_config() will configure the MAC in the new configuration using the
dpmac_set_link_state() MC firmware API.
- .mac_link_up() / .mac_link_down() will update the MAC link using the same
API described above.
At driver unbind() or when the DPNI object is disconnected from the DPMAC, the
dpaa2-eth driver calls dpaa2_mac_disconnect() which will, in turn, disconnect
from the PHY and destroy the PHYLINK instance.
In case of a DPNI-DPMAC connection, an 'ip link set dev eth0 up' would start
the following sequence of operations:
(1) phylink_start() called from .dev_open().
(2) The .mac_config() and .mac_link_up() callbacks are called by PHYLINK.
(3) In order to configure the HW MAC, the MC Firmware API
dpmac_set_link_state() is called.
(4) The firmware will eventually setup the HW MAC in the new configuration.
(5) A netif_carrier_on() call is made directly from PHYLINK on the associated
net_device.
(6) The dpaa2-eth driver handles the LINK_STATE_CHANGE irq in order to
enable/disable Rx taildrop based on the pause frame settings.
.. code-block:: none
+---------+ +---------+
| PHYLINK |-------------->| eth0 |
+---------+ (5) +---------+
(1) ^ |
| |
| v (2)
+-----------------------------------+
| dpaa2-eth |
+-----------------------------------+
| ^ (6)
| |
v (3) |
+---------+---------------+---------+
| DPMAC | | DPNI |
+---------+ +---------+
| MC Firmware |
+-----------------------------------+
|
|
v (4)
+-----------------------------------+
| HW MAC |
+-----------------------------------+
In case of a DPNI-DPNI connection, a usual sequence of operations looks like
the following:
(1) ip link set dev eth0 up
(2) The dpni_enable() MC API called on the associated fsl_mc_device.
(3) ip link set dev eth1 up
(4) The dpni_enable() MC API called on the associated fsl_mc_device.
(5) The LINK_STATE_CHANGED irq is received by both instances of the dpaa2-eth
driver because now the operational link state is up.
(6) The netif_carrier_on() is called on the exported net_device from
link_state_update().
.. code-block:: none
+---------+ +---------+
| eth0 | | eth1 |
+---------+ +---------+
| ^ ^ |
| | | |
(1) v | (6) (6) | v (3)
+---------+ +---------+
|dpaa2-eth| |dpaa2-eth|
+---------+ +---------+
| ^ ^ |
| | | |
(2) v | (5) (5) | v (4)
+---------+---------------+---------+
| DPNI | | DPNI |
+---------+ +---------+
| MC Firmware |
+-----------------------------------+
Exported API
------------
Any DPAA2 driver that drivers endpoints of DPMAC objects should service its
_EVENT_ENDPOINT_CHANGED irq and connect/disconnect from the associated DPMAC
when necessary using the below listed API::
- int dpaa2_mac_connect(struct dpaa2_mac *mac);
- void dpaa2_mac_disconnect(struct dpaa2_mac *mac);
A phylink integration is necessary only when the partner DPMAC is not of
``TYPE_FIXED``. This means it is either of ``TYPE_PHY``, or of
``TYPE_BACKPLANE`` (the difference being the two that in the ``TYPE_BACKPLANE``
mode, the MC firmware does not access the PCS registers). One can check for
this condition using the following helper::
- static inline bool dpaa2_mac_is_type_phy(struct dpaa2_mac *mac);
Before connection to a MAC, the caller must allocate and populate the
dpaa2_mac structure with the associated net_device, a pointer to the MC portal
to be used and the actual fsl_mc_device structure of the DPMAC.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
개요와 DPAA2 소프트웨어 아키텍처
1-26이 문서는 `GPL-2.0` 라이선스를 따르며 저작권은 © 2019 NXP에 있습니다.
DPAA2 MAC/PHY 지원
개요
DPAA2 MAC/PHY 지원은 `dpaa2-eth`, `dpaa2-ethsw` 같은 DPAA2 네트워크 드라이버가 PHY library와 상호 작용하도록 돕는 API 집합입니다.
DPAA2 소프트웨어 아키텍처
`fsl-mc` bus는 여러 DPAA2 객체 중 네트워크 인터페이스를 추상화한 DPNI 객체와 MAC을 추상화한 DPMAC 객체를 노출합니다.
`dpaa2-eth` 드라이버는 DPNI 객체를 probe하고 `phylink`의 도움으로 DPMAC 객체에 연결해 이를 구성합니다.
데이터 연결은 DPNI와 DPMAC 사이 또는 두 DPNI 사이에 만들 수 있습니다. 연결 유형에 따라 `netif_carrier_on()`과 `netif_carrier_off()` 처리는 `dpaa2-eth` 드라이버가 직접 수행하거나 `phylink`가 담당합니다.
.. SPDX-License-Identifier: GPL-2.0
.. include:: <isonum.txt>
=======================
DPAA2 MAC / PHY support
=======================
:Copyright: |copy| 2019 NXP
Overview
--------
The DPAA2 MAC / PHY support consists of a set of APIs that help DPAA2 network
drivers (dpaa2-eth, dpaa2-ethsw) interact with the PHY library.
DPAA2 Software Architecture
---------------------------
Among other DPAA2 objects, the fsl-mc bus exports DPNI objects (abstracting a
network interface) and DPMAC objects (abstracting a MAC). The dpaa2-eth driver
probes on the DPNI object and connects to and configures a DPMAC object with
the help of phylink.
Data connections may be established between a DPNI and a DPMAC, or between two
DPNIs. Depending on the connection type, the netif_carrier_[on/off] is handled
directly by the dpaa2-eth driver or by phylink.
링크 상태 정보 경로와 DPMAC 링크 유형
27-73MC firmware가 제공하는 추상화된 링크 상태 정보의 출처
원문의 첫 번째 ASCII 도식을 Linux, 외부 MDIO, MC firmware, 내부 PCS 경계로 다시 구성했습니다.
MC firmware 구성에 따라 각 MAC은 두 가지 모드 중 하나로 동작합니다.
`DPMAC_LINK_TYPE_FIXED`
MC firmware가 MAC PCS를 polling해 링크 상태를 전적으로 관리합니다. `phylink` instance를 등록할 필요가 없으므로 `dpaa2-eth` 드라이버는 연결된 DPMAC 객체에 전혀 bind하지 않습니다.
`DPMAC_LINK_TYPE_PHY`
MC firmware는 링크 상태 갱신 event를 기다리지만, 실제 event는 `phylink` 기반 `dpaa2-mac`과 여기에 연결된 `net_device` 드라이버(`dpaa2-eth`, `dpaa2-ethsw`) 사이에서만 전달됩니다. 따라서 firmware를 사실상 우회합니다.
.. code-block:: none
Sources of abstracted link state information presented by the MC firmware
+--------------------------------------+
+------------+ +---------+ | xgmac_mdio |
| net_device | | phylink |--| +-----+ +-----+ +-----+ +-----+ |
+------------+ +---------+ | | PHY | | PHY | | PHY | | PHY | |
| | | +-----+ +-----+ +-----+ +-----+ |
+------------------------------------+ | External MDIO bus |
| dpaa2-eth | +--------------------------------------+
+------------------------------------+
| | Linux
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | MC firmware
| /| V
+----------+ / | +----------+
| | / | | |
| | | | | |
| DPNI |<------| |<------| DPMAC |
| | | | | |
| | \ |<---+ | |
+----------+ \ | | +----------+
\| |
|
+--------------------------------------+
| MC firmware polling MAC PCS for link |
| +-----+ +-----+ +-----+ +-----+ |
| | PCS | | PCS | | PCS | | PCS | |
| +-----+ +-----+ +-----+ +-----+ |
| Internal MDIO bus |
+--------------------------------------+
Depending on an MC firmware configuration setting, each MAC may be in one of two modes:
- DPMAC_LINK_TYPE_FIXED: the link state management is handled exclusively by
the MC firmware by polling the MAC PCS. Without the need to register a
phylink instance, the dpaa2-eth driver will not bind to the connected dpmac
object at all.
- DPMAC_LINK_TYPE_PHY: The MC firmware is left waiting for link state update
events, but those are in fact passed strictly between the dpaa2-mac (based on
phylink) and its attached net_device driver (dpaa2-eth, dpaa2-ethsw),
effectively bypassing the firmware.
연결 구현, phylink callback과 해제
74-100구현
probe 시점이나 DPNI endpoint가 동적으로 바뀔 때 `dpaa2-eth`는 peer 객체가 DPMAC인지 확인해야 합니다.
peer가 DPMAC이면 `dpaa2_mac_connect()` API로 이를 PHYLINK와 통합합니다. 이 API는 다음 작업을 수행합니다.
- device tree에서 PHYLINK 호환 `of` binding인 `phy-handle` 검색
- 전달받은 `net_device`와 연결된 PHYLINK instance 생성
- `phylink_of_phy_connect()`로 PHY에 연결
다음 `phylink_mac_ops` callback이 구현되어 있습니다.
| callback | 동작 |
|---|---|
| `.validate()` | `phy_interface_t`가 `RGMII_*`일 때만 MAC capability로 지원 link mode를 채웁니다. 현재 드라이버가 지원하는 링크 유형은 이것뿐입니다. |
| `.mac_config()` | `dpmac_set_link_state()` MC firmware API로 MAC을 새 구성에 맞춥니다. |
| `.mac_link_up()` / `.mac_link_down()` | 같은 `dpmac_set_link_state()` API로 MAC 링크 상태를 갱신합니다. |
드라이버 `unbind()` 시점이나 DPNI 객체가 DPMAC에서 분리될 때 `dpaa2-eth`는 `dpaa2_mac_disconnect()`를 호출합니다. 이 함수는 PHY 연결을 끊고 PHYLINK instance를 파괴합니다.
Implementation
--------------
At probe time or when a DPNI's endpoint is dynamically changed, the dpaa2-eth
is responsible to find out if the peer object is a DPMAC and if this is the
case, to integrate it with PHYLINK using the dpaa2_mac_connect() API, which
will do the following:
- look up the device tree for PHYLINK-compatible of binding (phy-handle)
- will create a PHYLINK instance associated with the received net_device
- connect to the PHY using phylink_of_phy_connect()
The following phylink_mac_ops callback are implemented:
- .validate() will populate the supported linkmodes with the MAC capabilities
only when the phy_interface_t is RGMII_* (at the moment, this is the only
link type supported by the driver).
- .mac_config() will configure the MAC in the new configuration using the
dpmac_set_link_state() MC firmware API.
- .mac_link_up() / .mac_link_down() will update the MAC link using the same
API described above.
At driver unbind() or when the DPNI object is disconnected from the DPMAC, the
dpaa2-eth driver calls dpaa2_mac_disconnect() which will, in turn, disconnect
from the PHY and destroy the PHYLINK instance.
DPNI-DPMAC 링크 활성화 순서
101-140DPNI-DPMAC 연결에서 `ip link set dev eth0 up`을 실행하면 다음 순서로 동작합니다.
- (1) `.dev_open()`에서 `phylink_start()`를 호출합니다.
- (2) PHYLINK가 `.mac_config()`와 `.mac_link_up()` callback을 호출합니다.
- (3) 하드웨어 MAC 구성을 위해 MC firmware API `dpmac_set_link_state()`를 호출합니다.
- (4) firmware가 최종적으로 하드웨어 MAC을 새 구성으로 설정합니다.
- (5) PHYLINK가 연결된 `net_device`에서 직접 `netif_carrier_on()`을 호출합니다.
- (6) `dpaa2-eth` 드라이버가 `LINK_STATE_CHANGE` IRQ를 처리하고 pause frame 설정에 따라 Rx taildrop을 활성화하거나 비활성화합니다.
원문의 두 번째 ASCII 도식에 표시된 1~6번 호출과 event 경로를 다시 구성했습니다.
In case of a DPNI-DPMAC connection, an 'ip link set dev eth0 up' would start
the following sequence of operations:
(1) phylink_start() called from .dev_open().
(2) The .mac_config() and .mac_link_up() callbacks are called by PHYLINK.
(3) In order to configure the HW MAC, the MC Firmware API
dpmac_set_link_state() is called.
(4) The firmware will eventually setup the HW MAC in the new configuration.
(5) A netif_carrier_on() call is made directly from PHYLINK on the associated
net_device.
(6) The dpaa2-eth driver handles the LINK_STATE_CHANGE irq in order to
enable/disable Rx taildrop based on the pause frame settings.
.. code-block:: none
+---------+ +---------+
| PHYLINK |-------------->| eth0 |
+---------+ (5) +---------+
(1) ^ |
| |
| v (2)
+-----------------------------------+
| dpaa2-eth |
+-----------------------------------+
| ^ (6)
| |
v (3) |
+---------+---------------+---------+
| DPMAC | | DPNI |
+---------+ +---------+
| MC Firmware |
+-----------------------------------+
|
|
v (4)
+-----------------------------------+
| HW MAC |
+-----------------------------------+
DPNI-DPNI 내부 링크 활성화 순서
141-173DPNI-DPNI 연결의 일반적인 동작 순서는 다음과 같습니다.
- (1) `ip link set dev eth0 up`을 실행합니다.
- (2) 연결된 `fsl_mc_device`에서 `dpni_enable()` MC API를 호출합니다.
- (3) `ip link set dev eth1 up`을 실행합니다.
- (4) 두 번째 `fsl_mc_device`에서 `dpni_enable()` MC API를 호출합니다.
- (5) operational link state가 이제 up이므로 두 `dpaa2-eth` instance가 모두 `LINK_STATE_CHANGED` IRQ를 받습니다.
- (6) `link_state_update()`가 외부에 노출한 각 `net_device`에서 `netif_carrier_on()`을 호출합니다.
원문의 세 번째 ASCII 도식에 표시된 양쪽 인터페이스의 대칭 동작을 다시 구성했습니다.
In case of a DPNI-DPNI connection, a usual sequence of operations looks like
the following:
(1) ip link set dev eth0 up
(2) The dpni_enable() MC API called on the associated fsl_mc_device.
(3) ip link set dev eth1 up
(4) The dpni_enable() MC API called on the associated fsl_mc_device.
(5) The LINK_STATE_CHANGED irq is received by both instances of the dpaa2-eth
driver because now the operational link state is up.
(6) The netif_carrier_on() is called on the exported net_device from
link_state_update().
.. code-block:: none
+---------+ +---------+
| eth0 | | eth1 |
+---------+ +---------+
| ^ ^ |
| | | |
(1) v | (6) (6) | v (3)
+---------+ +---------+
|dpaa2-eth| |dpaa2-eth|
+---------+ +---------+
| ^ ^ |
| | | |
(2) v | (5) (5) | v (4)
+---------+---------------+---------+
| DPNI | | DPNI |
+---------+ +---------+
| MC Firmware |
+-----------------------------------+
외부 공개 API와 연결 전제 조건
174-194외부 공개 API
DPMAC 객체의 endpoint를 구동하는 모든 DPAA2 드라이버는 `_EVENT_ENDPOINT_CHANGED` IRQ를 처리해야 합니다. 필요할 때 다음 API로 연결된 DPMAC에 접속하거나 연결을 해제합니다.
int dpaa2_mac_connect(struct dpaa2_mac *mac);
void dpaa2_mac_disconnect(struct dpaa2_mac *mac);
partner DPMAC이 `TYPE_FIXED`가 아닐 때만 phylink 통합이 필요합니다. 즉 `TYPE_PHY` 또는 `TYPE_BACKPLANE`이어야 합니다.
`TYPE_BACKPLANE`에서는 MC firmware가 PCS register에 접근하지 않는다는 점이 `TYPE_PHY`와 다릅니다.
다음 helper로 이 조건을 확인할 수 있습니다.
static inline bool dpaa2_mac_is_type_phy(struct dpaa2_mac *mac);
MAC에 연결하기 전에 호출자는 `dpaa2_mac` 구조체를 할당해야 합니다. 연관된 `net_device`, 사용할 MC portal pointer, DPMAC의 실제 `fsl_mc_device` 구조체를 채워야 합니다.
Exported API
------------
Any DPAA2 driver that drivers endpoints of DPMAC objects should service its
_EVENT_ENDPOINT_CHANGED irq and connect/disconnect from the associated DPMAC
when necessary using the below listed API::
- int dpaa2_mac_connect(struct dpaa2_mac *mac);
- void dpaa2_mac_disconnect(struct dpaa2_mac *mac);
A phylink integration is necessary only when the partner DPMAC is not of
``TYPE_FIXED``. This means it is either of ``TYPE_PHY``, or of
``TYPE_BACKPLANE`` (the difference being the two that in the ``TYPE_BACKPLANE``
mode, the MC firmware does not access the PCS registers). One can check for
this condition using the following helper::
- static inline bool dpaa2_mac_is_type_phy(struct dpaa2_mac *mac);
Before connection to a MAC, the caller must allocate and populate the
dpaa2_mac structure with the associated net_device, a pointer to the MC portal
to be used and the actual fsl_mc_device structure of the DPMAC.
요약·해설
mac-phy-support.rst:1-194이 계층은 MC 객체 모델과 Linux PHYLINK 사이의 번역기 역할을 합니다. DPNI-DPMAC 연결에서는 phylink가 외부 PHY와 MAC callback을 관리하고, 고정 링크에서는 MC firmware가 PCS를 직접 polling합니다. DPNI끼리 연결될 때는 firmware IRQ를 통해 양쪽 carrier 상태를 맞춥니다.
링크 구성에 참여하는 객체와 계층입니다.
DPNI는 외부 PHY 또는 다른 DPNI와 연결될 수 있습니다.
원문의 첫 번째 ASCII 도식을 외부 PHY와 내부 PCS 경로로 분리했습니다.
링크 상태를 누가 관리하는지가 가장 큰 차이입니다.
`dpaa2_mac_connect()`가 수행하는 세 단계입니다.
현재 지원 링크 형식과 firmware 호출을 정리했습니다.
unbind 또는 endpoint 분리 때 PHYLINK 자원을 역순으로 정리합니다.
원문의 두 번째 ASCII 도식에 있는 1~6번 순서입니다.
원문의 세 번째 ASCII 도식처럼 두 인터페이스가 대칭으로 활성화됩니다.
endpoint 변경 IRQ 처리에서 사용하는 연결 API입니다.
partner DPMAC 유형에 따른 통합 여부입니다.
호출자가 구조체에 채워야 하는 필드입니다.