ehea: dynamic add / remove port
Subsystems (2)
PATCH 1/1 ehea: dynamic add / remove port
This patch enables dynamic adding / removing of ehea ports by DLPAR tool.
---
drivers/net/ehea/ehea.h +4 -3
@@ -39,7 +39,7 @@#include <asm/io.h> #define DRV_NAME "ehea" -#define DRV_VERSION "EHEA_0046" +#define DRV_VERSION "EHEA_0047"#define EHEA_MSG_DEFAULT (NETIF_MSG_LINK | NETIF_MSG_TIMER \ | NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR)
@@ -380,10 +380,11 @@ struct ehea_port_res { }; +#define EHEA_MAX_PORTS 16struct ehea_adapter {u64 handle; -u8 num_ports; -struct ehea_port *port[16 ]; +struct ibmebus_dev *ebus_dev; +struct ehea_port *port[EHEA_MAX_PORTS ];struct ehea_eq *neq;/* notification event queue */ struct workqueue_struct *ehea_wq;struct tasklet_struct neq_tasklet;
drivers/net/ehea/ehea_main.c +214 -121
464 lines not on this page · raw message
Hi-
A few high level comments, then some really insignificant ones.
First, is there a reason why we shouldn't have a sysfs entry/kobject for each logical port? How is it possible to determine, from the adapter sysfs directory, the current number of ports for that adapter? A port sysfs directory could include attributes like the OF path to the port, the state of the port, etc etc.
Second, the probe and remove functions do not communicate whether an add or remove was successful. Combine this with the lack of port information in the adapter sysfs directory, and the userspace tool has no way of verifying a dynamic add/remove.
+ dn_log_port_id = (u32*)get_property(eth_dn, "ibm,hea-port-no",
+ NULL);
+ if (!dn_log_port_id) {
+ ehea_error("bad device node: dn_log_port_id=%p",
+ dn_log_port_id);
Wouldn't this print NULL every time for dn_log_port_id? Would the OF path for eth_dn make for a more useful error msg?
+ ehea_info("%s -> logial port id #%d",
Spelling :)
if (port_setup_ok)
- ret = 0; /* At least some ports are setup correctly */
+ return 0; /* At least some ports are setup correctly */
else
- ret = -EINVAL;
+ return -EINVAL;
The else is unnecessary.
static int __devexit ehea_remove(struct ibmebus_dev *dev) {
struct ehea_adapter *adapter = dev->ofdev.dev.driver_data; u64 hret;
int i;
- for (i = 0; i < adapter->num_ports; i++)
+ for (i = 0; i < EHEA_MAX_PORTS; i++)
if (adapter->port[i]) {
ehea_shutdown_single_port(adapter->port[i]); adapter->port[i] = NULL;
}
Else break?
Thanks-
John
Quoted 4 lines
Second, the probe and remove functions do not communicate whether an add or remove was successful. Combine this with the lack of port information in the adapter sysfs directory, and the userspace tool has no way of verifying a dynamic add/remove.
One way to communicate a return code is by making the sysfs interface file read/write, and having the read callback give a return code. For an example of this, you can look at drivers/pci/rpadlpar_sysfs.c and rpadlpar_core.c.
It would still be nice to have some way from the adapter sysfs directory to list/examine logical ports. Symlinks would work, but it would be even nicer to have a new kobject per port with attribute files for logical id, state, etc.
Hi,
I agree with most points. Here the new design proposal:
Quoted 9 lines · John Rose
Hi-
A few high level comments, then some really insignificant ones.
First, is there a reason why we shouldn't have a sysfs entry/kobject for each logical port? How is it possible to determine, from the adapter sysfs directory, the current number of ports for that adapter? A port sysfs directory could include attributes like the OF path to the port, the state of the port, etc etc.
I think it is not necessary to have a special entry/kobject for each logical port. I suggest we use SET_NETDEV_DEV to create links to all ethernet devices that represent each a logical port. This should be in sync with all other ethernet drivers. Port attributes like the "logical port id" that might be need by the userspace application can be added to the net:ethX entry (link created with SET_NETDEV_DEV) as additional attributes.
Thus we have a simple and consistent way to determine
all currently available network interfaces (logical ports) and its corresponding IDs.
Quoted 5 lines
Second, the probe and remove functions do not communicate whether an add or remove was successful. Combine this with the lack of port information in the adapter sysfs directory, and the userspace tool has no way of verifying a dynamic add/remove.
True. I suggest we return error codes (-EIO / -EINVAL) in case the adding or removing of ports fails. This is possible as we know instantly if the operation failed or not. It is a synchronus operation.
Quoted 4 lines
drivers/net/ehea/ehea_main.c +1
-0+ ehea_info("%s -> logial port id #%d",Spelling :)
true, fixed
Quoted 9 lines
drivers/net/ehea/ehea_main.c +2
-2if (port_setup_ok) - ret =0 ;/* At least some ports are setup correctly */ +return 0 ;/* At least some ports are setup correctly */ else - ret = -EINVAL ; +return -EINVAL ;The else is unnecessary.
agreed, fixed
Quoted 14 lines
static int
__devexitehea_remove(struct ibmebus_dev *dev){drivers/net/ehea/ehea_main.c +1
-1struct ehea_adapter *adapter = dev->ofdev.dev.driver_data;u64 hret;int i; -for (i =0 ; i < adapter->num_ports; i++) +for (i =0 ; i <EHEA_MAX_PORTS ; i++)if (adapter->port[i]) {ehea_shutdown_single_port (adapter->port[i]); adapter->port[i] =NULL ; }
Quoted 1 line
Else break?
no break wanted here as "remove_port" might cause situations where not all currently available ports are in a row
Regards,
Jan-Bernd
Hi-
Sounds good. A couple of questions/comments:
Quoted 6 lines
I think it is not necessary to have a special entry/kobject for each logical port. I suggest we use
SET_NETDEV_DEVto create links to all ethernet devices that represent each a logical port. This should be in sync with all other ethernet drivers. Port attributes like the "logical port id" that might be need by the userspace application can be added to the net:ethX entry (link created withSET_NETDEV_DEV) as additional attributes.
As we develop the userspace tool, we are finding a need to know the following for each logical port:
1) the linux interface/device (a symlink would do this)
2) the logical port number - were you suggesting communicating this through the name of the symlink, or in the directory of the symlink target?
3) the open firmware path for the logical port. This is typically communicated through a sysfs attribute file "devspec", but we can't do this without a new kobject for the port.
Quoted 9 lines
Quoted 5 lines
Second, the probe and remove functions do not communicate whether an add or remove was successful. Combine this with the lack of port information in the adapter sysfs directory, and the userspace tool has no way of verifying a dynamic add/remove.
True. I suggest we return error codes (
-EIO/-EINVAL) in case the adding or removing of ports fails. This is possible as we know instantly if the operation failed or not. It is a synchronus operation.
Sounds good.
Thanks!
John