Lines Matching +full:1000 +full:- +full:10000
1 // SPDX-License-Identifier: GPL-2.0-only
14 * struct sfp_bus - internal representation of a sfp bus
36 * sfp_parse_port() - Parse the EEPROM base ID, setting the port type
43 * %PORT_TP, %PORT_FIBRE or %PORT_OTHER. If @support is non-%NULL,
55 switch (id->base.connector) { in sfp_parse_port()
76 if (id->base.e1000_base_t) { in sfp_parse_port()
88 dev_warn(bus->sfp_dev, "SFP: unknown connector id 0x%02x\n", in sfp_parse_port()
89 id->base.connector); in sfp_parse_port()
111 * sfp_may_have_phy() - indicate whether the module may have a PHY
120 if (id->base.e1000_base_t) in sfp_may_have_phy()
123 if (id->base.phys_id != SFF8024_ID_DWDM_SFP) { in sfp_may_have_phy()
124 switch (id->base.extended_cc) { in sfp_may_have_phy()
138 * sfp_parse_support() - Parse the eeprom id for supported link modes
156 if (id->base.br_nominal) { in sfp_parse_support()
157 if (id->base.br_nominal != 255) { in sfp_parse_support()
158 br_nom = id->base.br_nominal * 100; in sfp_parse_support()
159 br_min = br_nom - id->base.br_nominal * id->ext.br_min; in sfp_parse_support()
160 br_max = br_nom + id->base.br_nominal * id->ext.br_max; in sfp_parse_support()
161 } else if (id->ext.br_max) { in sfp_parse_support()
162 br_nom = 250 * id->ext.br_max; in sfp_parse_support()
163 br_max = br_nom + br_nom * id->ext.br_min / 100; in sfp_parse_support()
164 br_min = br_nom - br_nom * id->ext.br_min / 100; in sfp_parse_support()
171 if (br_min == br_max && id->base.sfp_ct_passive) in sfp_parse_support()
176 if (id->base.e10g_base_sr) { in sfp_parse_support()
177 phylink_set(modes, 10000baseSR_Full); in sfp_parse_support()
180 if (id->base.e10g_base_lr) { in sfp_parse_support()
181 phylink_set(modes, 10000baseLR_Full); in sfp_parse_support()
184 if (id->base.e10g_base_lrm) { in sfp_parse_support()
185 phylink_set(modes, 10000baseLRM_Full); in sfp_parse_support()
188 if (id->base.e10g_base_er) { in sfp_parse_support()
189 phylink_set(modes, 10000baseER_Full); in sfp_parse_support()
192 if (id->base.e1000_base_sx || in sfp_parse_support()
193 id->base.e1000_base_lx || in sfp_parse_support()
194 id->base.e1000_base_cx) { in sfp_parse_support()
195 phylink_set(modes, 1000baseX_Full); in sfp_parse_support()
198 if (id->base.e1000_base_t) { in sfp_parse_support()
199 phylink_set(modes, 1000baseT_Half); in sfp_parse_support()
200 phylink_set(modes, 1000baseT_Full); in sfp_parse_support()
205 /* 1000Base-PX or 1000Base-BX10 */ in sfp_parse_support()
206 if ((id->base.e_base_px || id->base.e_base_bx10) && in sfp_parse_support()
208 phylink_set(modes, 1000baseX_Full); in sfp_parse_support()
212 /* 100Base-FX, 100Base-LX, 100Base-PX, 100Base-BX10 */ in sfp_parse_support()
213 if (id->base.e100_base_fx || id->base.e100_base_lx) { in sfp_parse_support()
217 if ((id->base.e_base_px || id->base.e_base_bx10) && br_nom == 100) { in sfp_parse_support()
225 if ((id->base.sfp_ct_passive || id->base.sfp_ct_active) && br_nom) { in sfp_parse_support()
228 phylink_set(modes, 10000baseCR_Full); in sfp_parse_support()
236 phylink_set(modes, 1000baseX_Full); in sfp_parse_support()
240 if (id->base.sfp_ct_passive) { in sfp_parse_support()
241 if (id->base.passive.sff8431_app_e) { in sfp_parse_support()
242 phylink_set(modes, 10000baseCR_Full); in sfp_parse_support()
246 if (id->base.sfp_ct_active) { in sfp_parse_support()
247 if (id->base.active.sff8431_app_e || in sfp_parse_support()
248 id->base.active.sff8431_lim) { in sfp_parse_support()
249 phylink_set(modes, 10000baseCR_Full); in sfp_parse_support()
254 switch (id->base.extended_cc) { in sfp_parse_support()
259 /* 25GBASE-R, possibly with FEC */ in sfp_parse_support()
286 phylink_set(modes, 10000baseT_Full); in sfp_parse_support()
298 dev_warn(bus->sfp_dev, in sfp_parse_support()
300 id->base.extended_cc); in sfp_parse_support()
305 if (id->base.fc_speed_100 || in sfp_parse_support()
306 id->base.fc_speed_200 || in sfp_parse_support()
307 id->base.fc_speed_400) { in sfp_parse_support()
308 if (id->base.br_nominal >= 31) { in sfp_parse_support()
312 if (id->base.br_nominal >= 12) { in sfp_parse_support()
313 phylink_set(modes, 1000baseX_Full); in sfp_parse_support()
320 * 1310nm/1550nm) are not 1000BASE-BX compliant due to the differing in sfp_parse_support()
323 * Do the same for modules supporting 2500BASE-X. Note that some in sfp_parse_support()
325 * 2500BASE-X, so we allow some slack here. in sfp_parse_support()
329 phylink_set(modes, 1000baseX_Full); in sfp_parse_support()
342 if (bus->sfp_quirk && bus->sfp_quirk->modes) in sfp_parse_support()
343 bus->sfp_quirk->modes(id, modes, interfaces); in sfp_parse_support()
350 * sfp_select_interface() - Select appropriate phy_interface_t mode
365 if (phylink_test(link_modes, 10000baseCR_Full) || in sfp_select_interface()
366 phylink_test(link_modes, 10000baseSR_Full) || in sfp_select_interface()
367 phylink_test(link_modes, 10000baseLR_Full) || in sfp_select_interface()
368 phylink_test(link_modes, 10000baseLRM_Full) || in sfp_select_interface()
369 phylink_test(link_modes, 10000baseER_Full) || in sfp_select_interface()
370 phylink_test(link_modes, 10000baseT_Full)) in sfp_select_interface()
380 if (phylink_test(link_modes, 1000baseT_Half) || in sfp_select_interface()
381 phylink_test(link_modes, 1000baseT_Full)) in sfp_select_interface()
384 if (phylink_test(link_modes, 1000baseX_Full)) in sfp_select_interface()
390 dev_warn(bus->sfp_dev, "Unable to ascertain link mode\n"); in sfp_select_interface()
401 return bus->registered ? bus->upstream_ops : NULL; in sfp_get_upstream_ops()
413 if (sfp->fwnode == fwnode) { in sfp_bus_get()
414 kref_get(&sfp->kref); in sfp_bus_get()
421 kref_init(&new->kref); in sfp_bus_get()
422 new->fwnode = fwnode; in sfp_bus_get()
423 list_add(&new->node, &sfp_buses); in sfp_bus_get()
439 list_del(&bus->node); in sfp_bus_release()
445 * sfp_bus_put() - put a reference on the &struct sfp_bus
454 kref_put_mutex(&bus->kref, sfp_bus_release, &sfp_mutex); in sfp_bus_put()
460 const struct sfp_upstream_ops *ops = bus->upstream_ops; in sfp_register_bus()
464 if (ops->link_down) in sfp_register_bus()
465 ops->link_down(bus->upstream); in sfp_register_bus()
466 if (ops->connect_phy && bus->phydev) { in sfp_register_bus()
467 ret = ops->connect_phy(bus->upstream, bus->phydev); in sfp_register_bus()
472 bus->registered = true; in sfp_register_bus()
473 bus->socket_ops->attach(bus->sfp); in sfp_register_bus()
474 if (bus->started) in sfp_register_bus()
475 bus->socket_ops->start(bus->sfp); in sfp_register_bus()
476 bus->upstream_ops->attach(bus->upstream, bus); in sfp_register_bus()
482 const struct sfp_upstream_ops *ops = bus->upstream_ops; in sfp_unregister_bus()
484 if (bus->registered) { in sfp_unregister_bus()
485 bus->upstream_ops->detach(bus->upstream, bus); in sfp_unregister_bus()
486 if (bus->started) in sfp_unregister_bus()
487 bus->socket_ops->stop(bus->sfp); in sfp_unregister_bus()
488 bus->socket_ops->detach(bus->sfp); in sfp_unregister_bus()
489 if (bus->phydev && ops && ops->disconnect_phy) in sfp_unregister_bus()
490 ops->disconnect_phy(bus->upstream, bus->phydev); in sfp_unregister_bus()
492 bus->registered = false; in sfp_unregister_bus()
496 * sfp_get_module_info() - Get the ethtool_modinfo for a SFP module
507 return bus->socket_ops->module_info(bus->sfp, modinfo); in sfp_get_module_info()
512 * sfp_get_module_eeprom() - Read the SFP module EEPROM
515 * @data: buffer to contain the EEPROM data (must be at least @ee->len bytes)
525 return bus->socket_ops->module_eeprom(bus->sfp, ee, data); in sfp_get_module_eeprom()
530 * sfp_get_module_eeprom_by_page() - Read a page from the SFP module EEPROM
545 return bus->socket_ops->module_eeprom_by_page(bus->sfp, page, extack); in sfp_get_module_eeprom_by_page()
550 * sfp_upstream_start() - Inform the SFP that the network device is up
560 if (bus->registered) in sfp_upstream_start()
561 bus->socket_ops->start(bus->sfp); in sfp_upstream_start()
562 bus->started = true; in sfp_upstream_start()
567 * sfp_upstream_stop() - Inform the SFP that the network device is down
577 if (bus->registered) in sfp_upstream_stop()
578 bus->socket_ops->stop(bus->sfp); in sfp_upstream_stop()
579 bus->started = false; in sfp_upstream_stop()
585 bus->upstream_ops = NULL; in sfp_upstream_clear()
586 bus->upstream = NULL; in sfp_upstream_clear()
590 * sfp_upstream_set_signal_rate() - set data signalling rate
592 * @rate_kbd: signalling rate in units of 1000 baud
604 if (bus->registered) in sfp_upstream_set_signal_rate()
605 bus->socket_ops->set_signal_rate(bus->sfp, rate_kbd); in sfp_upstream_set_signal_rate()
610 * sfp_bus_find_fwnode() - parse and locate the SFP bus from fwnode
618 * - on success, a pointer to the sfp_bus structure,
619 * - %NULL if no SFP is specified,
620 * - on failure, an error pointer value:
622 * - corresponding to the errors detailed for
624 * - %-ENOMEM if we failed to allocate the bus.
625 * - an error from the upstream's connect_phy() method.
635 if (ret == -ENOENT) in sfp_bus_find_fwnode()
648 return ERR_PTR(-ENOMEM); in sfp_bus_find_fwnode()
655 * sfp_bus_add_upstream() - parse and register the neighbouring device
665 * - on success, a pointer to the sfp_bus structure,
666 * - %NULL if no SFP is specified,
667 * - on failure, an error pointer value:
669 * - corresponding to the errors detailed for
671 * - %-ENOMEM if we failed to allocate the bus.
672 * - an error from the upstream's connect_phy() method.
684 kref_get(&bus->kref); in sfp_bus_add_upstream()
685 bus->upstream_ops = ops; in sfp_bus_add_upstream()
686 bus->upstream = upstream; in sfp_bus_add_upstream()
688 if (bus->sfp) { in sfp_bus_add_upstream()
705 * sfp_bus_del_upstream() - Delete a sfp bus
715 if (bus->sfp) in sfp_bus_del_upstream()
726 * sfp_get_name() - Get the SFP device name
733 * - The name of the SFP device registered with sfp_register_socket()
734 * - %NULL if no device was registered on @bus
740 if (bus->sfp_dev) in sfp_get_name()
741 return dev_name(bus->sfp_dev); in sfp_get_name()
753 if (ops && ops->connect_phy) in sfp_add_phy()
754 ret = ops->connect_phy(bus->upstream, phydev); in sfp_add_phy()
757 bus->phydev = phydev; in sfp_add_phy()
767 if (ops && ops->disconnect_phy) in sfp_remove_phy()
768 ops->disconnect_phy(bus->upstream, bus->phydev); in sfp_remove_phy()
769 bus->phydev = NULL; in sfp_remove_phy()
777 if (ops && ops->link_up) in sfp_link_up()
778 ops->link_up(bus->upstream); in sfp_link_up()
786 if (ops && ops->link_down) in sfp_link_down()
787 ops->link_down(bus->upstream); in sfp_link_down()
797 bus->sfp_quirk = quirk; in sfp_module_insert()
799 if (ops && ops->module_insert) in sfp_module_insert()
800 ret = ops->module_insert(bus->upstream, id); in sfp_module_insert()
810 if (ops && ops->module_remove) in sfp_module_remove()
811 ops->module_remove(bus->upstream); in sfp_module_remove()
813 bus->sfp_quirk = NULL; in sfp_module_remove()
822 if (ops && ops->module_start) in sfp_module_start()
823 ret = ops->module_start(bus->upstream); in sfp_module_start()
833 if (ops && ops->module_stop) in sfp_module_stop()
834 ops->module_stop(bus->upstream); in sfp_module_stop()
840 bus->sfp_dev = NULL; in sfp_socket_clear()
841 bus->sfp = NULL; in sfp_socket_clear()
842 bus->socket_ops = NULL; in sfp_socket_clear()
848 struct sfp_bus *bus = sfp_bus_get(dev->fwnode); in sfp_register_socket()
853 bus->sfp_dev = dev; in sfp_register_socket()
854 bus->sfp = sfp; in sfp_register_socket()
855 bus->socket_ops = ops; in sfp_register_socket()
857 if (bus->upstream_ops) { in sfp_register_socket()
877 if (bus->upstream_ops) in sfp_unregister_socket()