Lines Matching +full:page +full:- +full:offset
1 // SPDX-License-Identifier: GPL-2.0-only
10 u32 offset; member
12 u8 page; member
33 u32 offset = request->offset; in fallback_set_params() local
34 u32 length = request->length; in fallback_set_params()
36 if (request->page) in fallback_set_params()
37 offset = request->page * ETH_MODULE_EEPROM_PAGE_LEN + offset; in fallback_set_params()
39 if (modinfo->type == ETH_MODULE_SFF_8472 && in fallback_set_params()
40 request->i2c_address == 0x51) in fallback_set_params()
41 offset += ETH_MODULE_EEPROM_PAGE_LEN * 2; in fallback_set_params()
43 if (offset >= modinfo->eeprom_len) in fallback_set_params()
44 return -EINVAL; in fallback_set_params()
46 eeprom->cmd = ETHTOOL_GMODULEEEPROM; in fallback_set_params()
47 eeprom->len = length; in fallback_set_params()
48 eeprom->offset = offset; in fallback_set_params()
56 struct net_device *dev = reply->base.dev; in eeprom_fallback()
73 return -ENOMEM; in eeprom_fallback()
78 reply->data = data; in eeprom_fallback()
79 reply->length = eeprom.len; in eeprom_fallback()
92 const struct ethtool_ops *ops = dev->ethtool_ops; in get_module_eeprom_by_page()
94 if (dev->ethtool->module_fw_flash_in_progress) { in get_module_eeprom_by_page()
97 return -EBUSY; in get_module_eeprom_by_page()
100 if (dev->sfp_bus) in get_module_eeprom_by_page()
101 return sfp_get_module_eeprom_by_page(dev->sfp_bus, page_data, extack); in get_module_eeprom_by_page()
103 if (ops->get_module_eeprom_by_page) in get_module_eeprom_by_page()
104 return ops->get_module_eeprom_by_page(dev, page_data, extack); in get_module_eeprom_by_page()
106 return -EOPNOTSUPP; in get_module_eeprom_by_page()
116 struct net_device *dev = reply_base->dev; in eeprom_prepare_data()
119 page_data.offset = request->offset; in eeprom_prepare_data()
120 page_data.length = request->length; in eeprom_prepare_data()
121 page_data.i2c_address = request->i2c_address; in eeprom_prepare_data()
122 page_data.page = request->page; in eeprom_prepare_data()
123 page_data.bank = request->bank; in eeprom_prepare_data()
126 return -ENOMEM; in eeprom_prepare_data()
132 ret = get_module_eeprom_by_page(dev, &page_data, info->extack); in eeprom_prepare_data()
136 reply->length = ret; in eeprom_prepare_data()
137 reply->data = page_data.data; in eeprom_prepare_data()
147 if (ret == -EOPNOTSUPP) in eeprom_prepare_data()
161 return -EINVAL; in eeprom_parse_request()
163 request->i2c_address = nla_get_u8(tb[ETHTOOL_A_MODULE_EEPROM_I2C_ADDRESS]); in eeprom_parse_request()
164 request->offset = nla_get_u32(tb[ETHTOOL_A_MODULE_EEPROM_OFFSET]); in eeprom_parse_request()
165 request->length = nla_get_u32(tb[ETHTOOL_A_MODULE_EEPROM_LENGTH]); in eeprom_parse_request()
168 * EEPROM page without crossing low page boundary located at offset 128. in eeprom_parse_request()
173 request->page = nla_get_u8(tb[ETHTOOL_A_MODULE_EEPROM_PAGE]); in eeprom_parse_request()
174 if (request->page && request->offset < ETH_MODULE_EEPROM_PAGE_LEN) { in eeprom_parse_request()
176 "reading from lower half page is allowed for page 0 only"); in eeprom_parse_request()
177 return -EINVAL; in eeprom_parse_request()
180 if (request->offset < ETH_MODULE_EEPROM_PAGE_LEN && in eeprom_parse_request()
181 request->offset + request->length > ETH_MODULE_EEPROM_PAGE_LEN) { in eeprom_parse_request()
183 "reading cross half page boundary is illegal"); in eeprom_parse_request()
184 return -EINVAL; in eeprom_parse_request()
185 } else if (request->offset + request->length > ETH_MODULE_EEPROM_PAGE_LEN * 2) { in eeprom_parse_request()
187 "reading cross page boundary is illegal"); in eeprom_parse_request()
188 return -EINVAL; in eeprom_parse_request()
192 request->bank = nla_get_u8(tb[ETHTOOL_A_MODULE_EEPROM_BANK]); in eeprom_parse_request()
202 return nla_total_size(sizeof(u8) * request->length); /* _EEPROM_DATA */ in eeprom_reply_size()
211 return nla_put(skb, ETHTOOL_A_MODULE_EEPROM_DATA, reply->length, reply->data); in eeprom_fill_reply()
218 kfree(reply->data); in eeprom_cleanup_data()
238 NLA_POLICY_MAX(NLA_U32, ETH_MODULE_EEPROM_PAGE_LEN * 2 - 1),