drivers/net/ethernet/freescale/dpaa2/dpsw.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/freescale/dpaa2/dpsw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/freescale/dpaa2/dpsw.c- Extension
.c- Size
- 53219 bytes
- Lines
- 1662
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source 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 or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/fsl/mc.hdpsw.hdpsw-cmd.h
Detected Declarations
function build_if_id_bitmapfunction dpsw_openfunction dpsw_closefunction dpsw_enablefunction dpsw_disablefunction dpsw_resetfunction dpsw_set_irq_enablefunction dpsw_set_irq_maskfunction dpsw_get_irq_statusfunction dpsw_clear_irq_statusfunction dpsw_get_attributesfunction dpsw_if_set_link_cfgfunction dpsw_if_get_link_statefunction dpsw_if_set_tcifunction dpsw_if_get_tcifunction dpsw_if_set_stpfunction dpsw_if_get_counterfunction dpsw_if_enablefunction dpsw_if_disablefunction dpsw_if_get_attributesfunction dpsw_if_set_max_frame_lengthfunction dpsw_vlan_addfunction dpsw_vlan_add_iffunction dpsw_vlan_add_if_untaggedfunction dpsw_vlan_remove_iffunction dpsw_vlan_remove_if_untaggedfunction dpsw_vlan_removefunction dpsw_fdb_addfunction dpsw_fdb_removefunction dpsw_fdb_add_unicastfunction dpsw_fdb_dumpfunction dpsw_fdb_remove_unicastfunction dpsw_fdb_add_multicastfunction dpsw_fdb_remove_multicastfunction dpsw_ctrl_if_get_attributesfunction dpsw_ctrl_if_set_poolsfunction dpsw_ctrl_if_set_queuefunction dpsw_get_api_versionfunction dpsw_if_get_port_mac_addrfunction dpsw_ctrl_if_enablefunction dpsw_ctrl_if_disablefunction dpsw_set_egress_floodfunction dpsw_if_set_learning_modefunction dpsw_acl_addfunction dpsw_acl_removefunction dpsw_acl_add_iffunction dpsw_acl_remove_iffunction dpsw_acl_prepare_entry_cfg
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright 2014-2016 Freescale Semiconductor Inc.
* Copyright 2017-2021 NXP
*
*/
#include <linux/fsl/mc.h>
#include "dpsw.h"
#include "dpsw-cmd.h"
static void build_if_id_bitmap(__le64 *bmap, const u16 *id, const u16 num_ifs)
{
int i;
for (i = 0; (i < num_ifs) && (i < DPSW_MAX_IF); i++) {
if (id[i] < DPSW_MAX_IF)
bmap[id[i] / 64] |= cpu_to_le64(BIT_MASK(id[i] % 64));
}
}
/**
* dpsw_open() - Open a control session for the specified object
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @dpsw_id: DPSW unique ID
* @token: Returned token; use in subsequent API calls
*
* This function can be used to open a control session for an
* already created object; an object may have been declared in
* the DPL or by calling the dpsw_create() function.
* This function returns a unique authentication token,
* associated with the specific object ID and the specific MC
* portal; this token must be used in all subsequent commands for
* this specific object
*
* Return: '0' on Success; Error code otherwise.
*/
int dpsw_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int dpsw_id, u16 *token)
{
struct fsl_mc_command cmd = { 0 };
struct dpsw_cmd_open *cmd_params;
int err;
/* prepare command */
cmd.header = mc_encode_cmd_header(DPSW_CMDID_OPEN,
cmd_flags,
0);
cmd_params = (struct dpsw_cmd_open *)cmd.params;
cmd_params->dpsw_id = cpu_to_le32(dpsw_id);
/* send command to mc*/
err = mc_send_command(mc_io, &cmd);
if (err)
return err;
/* retrieve response parameters */
*token = mc_cmd_hdr_read_token(&cmd);
return 0;
}
/**
* dpsw_close() - Close the control session of the object
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPSW object
*
* After this function is called, no further operations are
* allowed on the object without opening a new control session.
*
* Return: '0' on Success; Error code otherwise.
*/
int dpsw_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token)
{
struct fsl_mc_command cmd = { 0 };
/* prepare command */
cmd.header = mc_encode_cmd_header(DPSW_CMDID_CLOSE,
cmd_flags,
token);
/* send command to mc*/
return mc_send_command(mc_io, &cmd);
}
/**
* dpsw_enable() - Enable DPSW functionality
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Annotation
- Immediate include surface: `linux/fsl/mc.h`, `dpsw.h`, `dpsw-cmd.h`.
- Detected declarations: `function build_if_id_bitmap`, `function dpsw_open`, `function dpsw_close`, `function dpsw_enable`, `function dpsw_disable`, `function dpsw_reset`, `function dpsw_set_irq_enable`, `function dpsw_set_irq_mask`, `function dpsw_get_irq_status`, `function dpsw_clear_irq_status`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
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.