Lines Matching +full:half +full:- +full:length
1 // SPDX-License-Identifier: GPL-2.0-only
11 u32 length; member
19 u32 length; member
33 u32 offset = request->offset; in fallback_set_params()
34 u32 length = request->length; in fallback_set_params() local
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()
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->sfp_bus) in get_module_eeprom_by_page()
95 return sfp_get_module_eeprom_by_page(dev->sfp_bus, page_data, extack); in get_module_eeprom_by_page()
97 if (ops->get_module_eeprom_by_page) in get_module_eeprom_by_page()
98 return ops->get_module_eeprom_by_page(dev, page_data, extack); in get_module_eeprom_by_page()
100 return -EOPNOTSUPP; in get_module_eeprom_by_page()
110 struct net_device *dev = reply_base->dev; in eeprom_prepare_data()
113 page_data.offset = request->offset; in eeprom_prepare_data()
114 page_data.length = request->length; in eeprom_prepare_data()
115 page_data.i2c_address = request->i2c_address; in eeprom_prepare_data()
116 page_data.page = request->page; in eeprom_prepare_data()
117 page_data.bank = request->bank; in eeprom_prepare_data()
118 page_data.data = kmalloc(page_data.length, GFP_KERNEL); in eeprom_prepare_data()
120 return -ENOMEM; in eeprom_prepare_data()
126 ret = get_module_eeprom_by_page(dev, &page_data, info->extack); in eeprom_prepare_data()
130 reply->length = ret; in eeprom_prepare_data()
131 reply->data = page_data.data; in eeprom_prepare_data()
141 if (ret == -EOPNOTSUPP) in eeprom_prepare_data()
155 return -EINVAL; in eeprom_parse_request()
157 request->i2c_address = nla_get_u8(tb[ETHTOOL_A_MODULE_EEPROM_I2C_ADDRESS]); in eeprom_parse_request()
158 request->offset = nla_get_u32(tb[ETHTOOL_A_MODULE_EEPROM_OFFSET]); in eeprom_parse_request()
159 request->length = nla_get_u32(tb[ETHTOOL_A_MODULE_EEPROM_LENGTH]); in eeprom_parse_request()
163 * This means user may only request dumps of length limited to 128 from in eeprom_parse_request()
167 request->page = nla_get_u8(tb[ETHTOOL_A_MODULE_EEPROM_PAGE]); in eeprom_parse_request()
168 if (request->page && request->offset < ETH_MODULE_EEPROM_PAGE_LEN) { in eeprom_parse_request()
170 "reading from lower half page is allowed for page 0 only"); in eeprom_parse_request()
171 return -EINVAL; in eeprom_parse_request()
174 if (request->offset < ETH_MODULE_EEPROM_PAGE_LEN && in eeprom_parse_request()
175 request->offset + request->length > ETH_MODULE_EEPROM_PAGE_LEN) { in eeprom_parse_request()
177 "reading cross half page boundary is illegal"); in eeprom_parse_request()
178 return -EINVAL; in eeprom_parse_request()
179 } else if (request->offset + request->length > ETH_MODULE_EEPROM_PAGE_LEN * 2) { in eeprom_parse_request()
182 return -EINVAL; in eeprom_parse_request()
186 request->bank = nla_get_u8(tb[ETHTOOL_A_MODULE_EEPROM_BANK]); in eeprom_parse_request()
196 return nla_total_size(sizeof(u8) * request->length); /* _EEPROM_DATA */ in eeprom_reply_size()
205 return nla_put(skb, ETHTOOL_A_MODULE_EEPROM_DATA, reply->length, reply->data); in eeprom_fill_reply()
212 kfree(reply->data); in eeprom_cleanup_data()
232 NLA_POLICY_MAX(NLA_U32, ETH_MODULE_EEPROM_PAGE_LEN * 2 - 1),