drivers/net/ethernet/synopsys/dwc-xlgmac-net.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/synopsys/dwc-xlgmac-net.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/synopsys/dwc-xlgmac-net.c- Extension
.c- Size
- 34815 bytes
- Lines
- 1351
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/netdevice.hlinux/tcp.hlinux/interrupt.hdwc-xlgmac.hdwc-xlgmac-reg.h
Detected Declarations
function xlgmac_tx_avail_descfunction xlgmac_rx_dirty_descfunction xlgmac_maybe_stop_tx_queuefunction xlgmac_prep_vlanfunction xlgmac_prep_tsofunction xlgmac_is_tsofunction xlgmac_prep_tx_pktfunction xlgmac_calc_rx_buf_sizefunction xlgmac_enable_rx_tx_intsfunction xlgmac_disable_rx_tx_intsfunction xlgmac_isrfunction xlgmac_dma_isrfunction xlgmac_tx_timerfunction xlgmac_init_timersfunction xlgmac_stop_timersfunction xlgmac_napi_enablefunction xlgmac_napi_disablefunction xlgmac_request_irqsfunction xlgmac_free_irqsfunction xlgmac_free_tx_datafunction xlgmac_free_rx_datafunction xlgmac_startfunction xlgmac_stopfunction xlgmac_restart_devfunction xlgmac_restartfunction xlgmac_openfunction xlgmac_closefunction xlgmac_tx_timeoutfunction xlgmac_xmitfunction xlgmac_get_stats64function xlgmac_set_mac_addressfunction xlgmac_ioctlfunction xlgmac_change_mtufunction xlgmac_vlan_rx_add_vidfunction xlgmac_vlan_rx_kill_vidfunction xlgmac_poll_controllerfunction xlgmac_set_featuresfunction xlgmac_set_rx_modefunction xlgmac_rx_refreshfunction xlgmac_tx_pollfunction xlgmac_rx_pollfunction xlgmac_one_pollfunction xlgmac_all_poll
Annotated Snippet
static const struct net_device_ops xlgmac_netdev_ops = {
.ndo_open = xlgmac_open,
.ndo_stop = xlgmac_close,
.ndo_start_xmit = xlgmac_xmit,
.ndo_tx_timeout = xlgmac_tx_timeout,
.ndo_get_stats64 = xlgmac_get_stats64,
.ndo_change_mtu = xlgmac_change_mtu,
.ndo_set_mac_address = xlgmac_set_mac_address,
.ndo_validate_addr = eth_validate_addr,
.ndo_eth_ioctl = xlgmac_ioctl,
.ndo_vlan_rx_add_vid = xlgmac_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid = xlgmac_vlan_rx_kill_vid,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = xlgmac_poll_controller,
#endif
.ndo_set_features = xlgmac_set_features,
.ndo_set_rx_mode = xlgmac_set_rx_mode,
};
const struct net_device_ops *xlgmac_get_netdev_ops(void)
{
return &xlgmac_netdev_ops;
}
static void xlgmac_rx_refresh(struct xlgmac_channel *channel)
{
struct xlgmac_pdata *pdata = channel->pdata;
struct xlgmac_ring *ring = channel->rx_ring;
struct xlgmac_desc_data *desc_data;
struct xlgmac_desc_ops *desc_ops;
struct xlgmac_hw_ops *hw_ops;
desc_ops = &pdata->desc_ops;
hw_ops = &pdata->hw_ops;
while (ring->dirty != ring->cur) {
desc_data = XLGMAC_GET_DESC_DATA(ring, ring->dirty);
/* Reset desc_data values */
desc_ops->unmap_desc_data(pdata, desc_data);
if (desc_ops->map_rx_buffer(pdata, ring, desc_data))
break;
hw_ops->rx_desc_reset(pdata, desc_data, ring->dirty);
ring->dirty++;
}
/* Make sure everything is written before the register write */
wmb();
/* Update the Rx Tail Pointer Register with address of
* the last cleaned entry
*/
desc_data = XLGMAC_GET_DESC_DATA(ring, ring->dirty - 1);
writel(lower_32_bits(desc_data->dma_desc_addr),
XLGMAC_DMA_REG(channel, DMA_CH_RDTR_LO));
}
static struct sk_buff *xlgmac_create_skb(struct xlgmac_pdata *pdata,
struct napi_struct *napi,
struct xlgmac_desc_data *desc_data,
unsigned int len)
{
unsigned int copy_len;
struct sk_buff *skb;
u8 *packet;
skb = napi_alloc_skb(napi, desc_data->rx.hdr.dma_len);
if (!skb)
return NULL;
/* Start with the header buffer which may contain just the header
* or the header plus data
*/
dma_sync_single_range_for_cpu(pdata->dev, desc_data->rx.hdr.dma_base,
desc_data->rx.hdr.dma_off,
desc_data->rx.hdr.dma_len,
DMA_FROM_DEVICE);
packet = page_address(desc_data->rx.hdr.pa.pages) +
desc_data->rx.hdr.pa.pages_offset;
copy_len = (desc_data->rx.hdr_len) ? desc_data->rx.hdr_len : len;
copy_len = min(desc_data->rx.hdr.dma_len, copy_len);
skb_copy_to_linear_data(skb, packet, copy_len);
skb_put(skb, copy_len);
len -= copy_len;
if (len) {
Annotation
- Immediate include surface: `linux/netdevice.h`, `linux/tcp.h`, `linux/interrupt.h`, `dwc-xlgmac.h`, `dwc-xlgmac-reg.h`.
- Detected declarations: `function xlgmac_tx_avail_desc`, `function xlgmac_rx_dirty_desc`, `function xlgmac_maybe_stop_tx_queue`, `function xlgmac_prep_vlan`, `function xlgmac_prep_tso`, `function xlgmac_is_tso`, `function xlgmac_prep_tx_pkt`, `function xlgmac_calc_rx_buf_size`, `function xlgmac_enable_rx_tx_ints`, `function xlgmac_disable_rx_tx_ints`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.