net/ethtool/cmis_cdb.c
Source file repositories/reference/linux-study-clean/net/ethtool/cmis_cdb.c
File Facts
- System
- Linux kernel
- Corpus path
net/ethtool/cmis_cdb.c- Extension
.c- Size
- 17295 bytes
- Lines
- 675
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/ethtool.hlinux/jiffies.hnet/netdev_lock.hcommon.hmodule_fw.hcmis.h
Detected Declarations
struct cmis_rev_rplstruct cmis_cdb_advert_rplstruct cmis_password_entry_plstruct cmis_cdb_query_status_plstruct cmis_cdb_query_status_rplstruct cmis_cdb_module_features_rplstruct cmis_wait_for_cond_rplfunction minfunction ethtool_cmis_cdb_compose_argsfunction ethtool_cmis_page_initfunction cmis_rev_rpl_majorfunction cmis_rev_major_getfunction cmis_cdb_advert_rpl_inst_supportedfunction cmis_cdb_advertisement_getfunction cmis_cdb_validate_passwordfunction ethtool_cmis_cdb_check_completion_flagfunction cmis_cdb_module_features_completion_timefunction cmis_cdb_module_features_getfunction ethtool_cmis_cdb_initfunction ethtool_cmis_cdb_finifunction is_completedfunction status_successfunction status_failfunction ethtool_cmis_module_pollfunction ethtool_cmis_wait_for_condfunction cmis_cdb_wait_for_completionfunction cmis_cdb_status_fail_msg_getfunction cmis_cdb_wait_for_statusfunction cmis_cdb_process_replyfunction __ethtool_cmis_cdb_execute_cmdfunction ethtool_cmis_cdb_execute_epl_cmdfunction cmis_cdb_calc_checksumfunction ethtool_cmis_cdb_execute_cmd
Annotated Snippet
struct cmis_rev_rpl {
u8 rev;
};
static u8 cmis_rev_rpl_major(struct cmis_rev_rpl *rpl)
{
return rpl->rev >> 4;
}
static int cmis_rev_major_get(struct net_device *dev, u8 *rev_major)
{
const struct ethtool_ops *ops = dev->ethtool_ops;
struct ethtool_module_eeprom page_data = {0};
struct netlink_ext_ack extack = {};
struct cmis_rev_rpl rpl = {};
int err;
ethtool_cmis_page_init(&page_data, CMIS_REVISION_PAGE,
CMIS_REVISION_OFFSET, sizeof(rpl));
page_data.data = (u8 *)&rpl;
err = ops->get_module_eeprom_by_page(dev, &page_data, &extack);
if (err < 0) {
if (extack._msg)
netdev_err(dev, "%s\n", extack._msg);
return err;
}
*rev_major = cmis_rev_rpl_major(&rpl);
return 0;
}
#define CMIS_CDB_ADVERTISEMENT_PAGE 0x01
#define CMIS_CDB_ADVERTISEMENT_OFFSET 0xA3
/* Based on section 8.4.11 "CDB Messaging Support Advertisement" in CMIS
* standard revision 5.2.
*/
struct cmis_cdb_advert_rpl {
u8 inst_supported;
u8 read_write_len_ext;
u8 resv1;
u8 resv2;
};
static u8 cmis_cdb_advert_rpl_inst_supported(struct cmis_cdb_advert_rpl *rpl)
{
return rpl->inst_supported >> 6;
}
static int cmis_cdb_advertisement_get(struct ethtool_cmis_cdb *cdb,
struct net_device *dev,
struct ethnl_module_fw_flash_ntf_params *ntf_params)
{
const struct ethtool_ops *ops = dev->ethtool_ops;
struct ethtool_module_eeprom page_data = {};
struct cmis_cdb_advert_rpl rpl = {};
struct netlink_ext_ack extack = {};
int err;
ethtool_cmis_page_init(&page_data, CMIS_CDB_ADVERTISEMENT_PAGE,
CMIS_CDB_ADVERTISEMENT_OFFSET, sizeof(rpl));
page_data.data = (u8 *)&rpl;
err = ops->get_module_eeprom_by_page(dev, &page_data, &extack);
if (err < 0) {
if (extack._msg)
netdev_err(dev, "%s\n", extack._msg);
return err;
}
if (!cmis_cdb_advert_rpl_inst_supported(&rpl)) {
ethnl_module_fw_flash_ntf_err(dev, ntf_params,
"CDB functionality is not supported",
NULL);
return -EOPNOTSUPP;
}
cdb->read_write_len_ext = rpl.read_write_len_ext;
return 0;
}
#define CMIS_PASSWORD_ENTRY_PAGE 0x00
#define CMIS_PASSWORD_ENTRY_OFFSET 0x7A
struct cmis_password_entry_pl {
__be32 password;
};
Annotation
- Immediate include surface: `linux/ethtool.h`, `linux/jiffies.h`, `net/netdev_lock.h`, `common.h`, `module_fw.h`, `cmis.h`.
- Detected declarations: `struct cmis_rev_rpl`, `struct cmis_cdb_advert_rpl`, `struct cmis_password_entry_pl`, `struct cmis_cdb_query_status_pl`, `struct cmis_cdb_query_status_rpl`, `struct cmis_cdb_module_features_rpl`, `struct cmis_wait_for_cond_rpl`, `function min`, `function ethtool_cmis_cdb_compose_args`, `function ethtool_cmis_page_init`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- 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.