atm : fix /sys/devices/virtual/atm/X/carrier(ATM_PHY_SIG_UNKNOWN)
Subsystems (6)
PATCH 1/1 atm : fix /sys/devices/virtual/atm/X/carrier(ATM_PHY_SIG_UNKNOWN)
When trying to design udev rules to automate usage of cxacru usb atm (adsl) modem, I have discovered that /sys/devices/virtual/atm/cxacru0/carrier had the value '1' while actually carrier was not yet established and real carrier state was not yet known to linux. I propose to fix that by using '?' as the /sys/devices/virtual/atm/cxacru0/carrier value when carrier state is not yet known to linux. Any other value except '1' would also be OK for me.
--
Currently, just after the interface creation, /sys/devices/virtual/atm/cxacru0/carrier gives wrong info (carrier = 1), while actually carrier is unknown. Fix that.
net/atm/atm_sysfs.c +3 -3
@@ -63,9 +63,9 @@ static ssize_t show_carrier(struct devicchar *pos = buf;struct atm_dev *adev =to_atm_dev (cdev); - pos +=sprintf (pos,"%d\n" , - adev->signal == - adev->signal ==ATM_PHY_SIG_LOST ?0 :1 ); + pos +=sprintf (pos,"%c\n" , + adev->signal ==ATM_PHY_SIG_FOUND ?'1' : + adev->signal ==ATM_PHY_SIG_LOST ?'0' :'?' );return pos - buf; }
Quoted 4 lines · In message <[email protected]>,Philippe De Muyter writes:
value '1' while actually carrier was not yet established and real carrier state was not yet known to linux. I propose to fix that by using '?' as the
/sys/devices/virtual/atm/cxacru0/carriervalue when carrier state is not yet known to linux. Any other value except '1' would also be OK for me.
this is sort of intentional because some drivers dont actually implement atm_dev->signal. ATM_PHY_SIG_UNKNOWN and ATM_PHY_SIG_LOST should likely be carrier = 0. if the driver doesnt isnt going to handle changing the state of atm_dev->signal it should just set the value to ATM_PHY_SIG_FOUND.
i dont like the idea of carrier being '?' -- carrier is either true or false. you have it or you dont.
Hi Chas,
Quoted 6 lines · Chas Williams (CONTRACTOR)
Quoted 4 lines · In message <[email protected]>,Philippe De Muyter writes:
value '1' while actually carrier was not yet established and real carrier state was not yet known to linux. I propose to fix that by using '?' as the
/sys/devices/virtual/atm/cxacru0/carriervalue when carrier state is not yet known to linux. Any other value except '1' would also be OK for me.
Quoted 8 lines
this is sort of intentional because some drivers dont actually implement
atm_dev->signal.ATM_PHY_SIG_UNKNOWNandATM_PHY_SIG_LOSTshould likely be carrier = 0. if the driver doesnt isnt going to handle changing the state ofatm_dev->signalit should just set the value toATM_PHY_SIG_FOUND.i dont like the idea of carrier being '?' -- carrier is either true or false. you have it or you dont.
OK for me. I would agree with
carrier = 0 when signal == ATM_PHY_SIG_UNKNOWN,
but currently we have
carrier = 1 when signal == ATM_PHY_SIG_UNKNOWN
cxacru itself does the right thing : as soon as carrier state is known, signal is set to ATM_PHY_SIG_LOST or ATM_PHY_SIG_FOUND, but atm_sysfs.c::show_carrier is wrong.
So here is a revised patch :
--
The carrier field of /sys/devices/virtual/atm/cxacru0 shows 1 when carrier is actually down (but unknown to linux). Make it show 0 instead in that case.
net/atm/atm_sysfs.c +1 -2
@@ -63,8 +63,7 @@ static ssize_t show_carrier(struct devicchar *pos = buf;struct atm_dev *adev =to_atm_dev (cdev); - pos +=sprintf (pos,"%d\n" , - adev->signal ==ATM_PHY_SIG_LOST ?0 :1 ); + pos +=sprintf (pos,"%d\n" , adev->signal ==ATM_PHY_SIG_FOUND );return pos - buf; }
Quoted 7 lines · In message <[email protected]>,Philippe De Muyter writes:
OK for me. I would agree with
carrier = 0 when signal == ATM_PHY_SIG_UNKNOWN,but currently we have
carrier = 1 when signal == ATM_PHY_SIG_UNKNOWN
not quite what i said (or perhaps i didnt clearly convey my intent). ATM_PHY_SIG_UNKNOWN is set during the driver create/initialize. unfortunately, some drivers never bothers to set signal so it winds up always being unknown. however, for those drivers, we cant assume the carrier is 0, or nothing will happen if someone is watching for the carrier to be 1.
so, all drivers, if they arent going to support setting signal should just assign it to 1. i would sort of prefer that ATM_PHY_SIG_UNKNOWN simply didnt exist. as i said before there is carrier or there is not. if the driver doesnt support checking/knowing the carrier status it should simply say 'yes i have carrier'.
i will see if i cant workup a little patch for this today.
David Miller
maintainerFrom: "Chas Williams (CONTRACTOR)" <[email protected]>
Date: Sun, 14 Feb 2010 16:34:40 -0500
Quoted 3 lines
as i said before there is carrier or there is not. if the driver doesnt support checking/knowing the carrier status it should simply say 'yes i have carrier'.
I agree %100 and this is how we handle similar situations for other networking device types.
Hi Chas, David,
Quoted 9 lines · David Miller
From: "Chas Williams (CONTRACTOR)" <[email protected]>
Date: Sun, 14 Feb 2010 16:34:40 -0500Quoted 3 lines
as i said before there is carrier or there is not. if the driver doesnt support checking/knowing the carrier status it should simply say 'yes i have carrier'.
I agree %100 and this is how we handle similar situations for other networking device types.
I also agree 100% with that : the low-level driver must do that, not the generic class driver. Here cxacru is punished because other atm drivers forget to set signal = ATM_PHY_SIG_FOUND.
Philippe
Quoted 3 lines · In message <[email protected]>,Philippe De Muyter writes:
cxacru itself does the right thing : as soon as carrier state is known, signal is set to
ATM_PHY_SIG_LOSTorATM_PHY_SIG_FOUND, butatm_sysfs.c::show_carrieris wrong.
so, i was thinking about something like this. atm_dev->signal is initializated to _LOST (because it is at this point), but most drivers will set ->signal to _FOUND since they dont handle detecting carrier when they finish their hardware initialization. the usb atm layer is the major exception here, and it appears that they already handle the atm_dev->signal status correctly. the minor exception being "unknown line state" -- i am going to assume LOST is the best choice for this case.
please try this and let me know if it fixes your problem.
drivers/atm/adummy.c +1 -0
@@ -134,6 +134,7 @@ static int __init adummy_init(void) }list_add (&adummy_dev->entry, &adummy_devs); + atm_dev->signal =ATM_PHY_SIG_FOUND ; out:return err;
drivers/atm/ambassador.c +1 -0
@@ -2269,6 +2269,7 @@ static int __devinit amb_probe(struct pci_dev *pci_dev, const struct pci_device_// enable host interrupts interrupts_on (dev); + dev->atm_dev->signal =ATM_PHY_SIG_FOUND ; out:return err;
drivers/atm/atmtcp.c +1 -0
@@ -375,6 +375,7 @@ static int atmtcp_create(int itf,int persist,struct atm_dev **result) dev->dev_data = dev_data;PRIV (dev)->vcc =NULL ;PRIV (dev)->persist = persist; + dev->signal =ATM_PHY_SIG_FOUND ;if (result) *result = dev;return 0 ; }
drivers/atm/firestream.c +1 -0
@@ -1923,6 +1923,7 @@ static int __devinit firestream_init_one (struct pci_dev *pci_dev, fs_dev->next = fs_boards; fs_boards = fs_dev; + atm_dev->signal =ATM_PHY_SIG_FOUND ;return 0 ; err_out_free_atm_dev:
drivers/atm/fore200e.c +1 -0
@@ -2637,6 +2637,7 @@ fore200e_init(struct fore200e* fore200e)/* all done, board initialization is now complete */ fore200e->state =FORE200E_STATE_COMPLETE ; + fore200e->atm_dev->signal =ATM_PHY_SIG_FOUND ;return 0 ; }
drivers/atm/he.c +2 -0
@@ -1528,6 +1528,8 @@ he_start(struct atm_dev *dev)suni_init (he_dev->atm_dev);if (he_dev->atm_dev->phy && he_dev->atm_dev->phy->start) he_dev->atm_dev->phy->start (he_dev->atm_dev); +#else + he_dev->atm_dev->signal =ATM_PHY_SIG_FOUND ;#endif /* CONFIG_ATM_HE_USE_SUNI */ if (sdh) {
drivers/atm/horizon.c +1 -0
@@ -2827,6 +2827,7 @@ static int __devinit hrz_probe(struct pci_dev *pci_dev, const struct pci_device_ dev->housekeeping.data = (unsigned long ) dev;mod_timer (&dev->housekeeping, jiffies); + dev->atm_dev->signal =ATM_PHY_SIG_FOUND ; out:return err;
drivers/atm/idt77252.c +2 -0
@@ -3715,6 +3715,8 @@ idt77252_init_one(struct pci_dev *pcidev, const struct pci_device_id *id) err = -EIO ; goto err_out_deinit_card; } +#else + dev->signal =ATM_PHY_SIG_FOUND ;#endif /* CONFIG_ATM_IDT77252_USE_SUNI */ card->sramsize =probe_sram (card);
drivers/atm/lanai.c +1 -0
@@ -2250,6 +2250,7 @@ static int __devinit lanai_dev_open(struct atm_dev *atmdev)"board_rev=%d\n" , lanai->number, lanai->type==lanai2 ?"2" :"HB" , (unsigned int ) lanai->serialno, (unsigned int) lanai->serialno, lanai->board_rev); + atmdev->signal =ATM_PHY_SIG_FOUND ;return 0 ; error_vcctable:
drivers/atm/nicstar.c +6 -2
@@ -815,14 +815,18 @@ static int __devinit ns_init_card(int i, struct pci_dev *pcidev) card->atmdev->link_rate = card->max_pcr; card->atmdev->phy =NULL ; -#ifdef CONFIG_ATM_NICSTAR_USE_SUNI if (card->max_pcr == ATM_OC3_PCR) +#ifdef CONFIG_ATM_NICSTAR_USE_SUNI suni_init (card->atmdev); +#else + card->atmdev->signal =ATM_PHY_SIG_FOUND ;#endif /* CONFIG_ATM_NICSTAR_USE_SUNI */ -#ifdef CONFIG_ATM_NICSTAR_USE_IDT77105 if (card->max_pcr == ATM_25_PCR) +#ifdef CONFIG_ATM_NICSTAR_USE_IDT77105 idt77105_init (card->atmdev); +#else + card->atmdev->signal =ATM_PHY_SIG_FOUND ;#endif /* CONFIG_ATM_NICSTAR_USE_IDT77105 */ if (card->atmdev->phy && card->atmdev->phy->start)
drivers/atm/solos-pci.c +1 -1
@@ -1245,7 +1245,7 @@ static int atm_init(struct solos_card *card) card->atmdev[i]->ci_range.vci_bits =16 ; card->atmdev[i]->dev_data = card; card->atmdev[i]->phy_data = (void *)(unsigned long )i; - card->atmdev[i]->signal =ATM_PHY_SIG_UNKNOWN ; + card->atmdev[i]->signal =ATM_PHY_SIG_LOST ; skb =alloc_skb (sizeof (*header),GFP_ATOMIC );if (!skb) {
drivers/atm/zatm.c +2 -0
@@ -1345,6 +1345,8 @@ static int __devinit zatm_start(struct atm_dev *dev)zout (0xffffffff ,IMR );/* enable interrupts */ /* enable TX & RX */ zout (zin (GMR ) | uPD98401_GMR_SE | uPD98401_GMR_RE,GMR ); + + dev->signal =ATM_PHY_SIG_FOUND ; done:return error;
drivers/usb/atm/cxacru.c +1 -1
@@ -803,7 +803,7 @@ static void cxacru_poll_status(struct work_struct *work)break ;default : - atm_dev->signal =ATM_PHY_SIG_UNKNOWN ; + atm_dev->signal =ATM_PHY_SIG_LOST ;atm_info (usbatm,"Unknown line state %02x\n" , instance->line_status);break ; }
drivers/usb/atm/speedtch.c +2 -2
@@ -536,7 +536,7 @@ static void speedtch_check_status(struct work_struct *work)break ;case 0x08 : - atm_dev->signal =ATM_PHY_SIG_UNKNOWN ; + atm_dev->signal =ATM_PHY_SIG_LOST ;atm_info (usbatm,"ADSL line is blocked?\n" );break ;
@@ -565,7 +565,7 @@ static void speedtch_check_status(struct work_struct *work)break ;default : - atm_dev->signal =ATM_PHY_SIG_UNKNOWN ; + atm_dev->signal =ATM_PHY_SIG_LOST ;atm_info (usbatm,"unknown line state %02x\n" , status);break ; }
drivers/usb/atm/usbatm.c +1 -1
@@ -963,7 +963,7 @@ static int usbatm_atm_init(struct usbatm_data *instance) atm_dev->ci_range.vpi_bits =ATM_CI_MAX ; atm_dev->ci_range.vci_bits =ATM_CI_MAX ; - atm_dev->signal =ATM_PHY_SIG_UNKNOWN ; + atm_dev->signal =ATM_PHY_SIG_LOST ;/* temp init ATM device, set to 128kbit */ atm_dev->link_rate =128 *1000 /424 ;
include/linux/atmdev.h +0 -1
@@ -290,7 +290,6 @@ enum {#define ATM_PHY_SIG_LOST 0/* no carrier/light */ -#define ATM_PHY_SIG_UNKNOWN 1/* carrier/light status is unknown */ #define ATM_PHY_SIG_FOUND 2/* carrier/light okay */ #define ATM_ATMOPT_CLP 1/* set CLP bit */
net/atm/atm_sysfs.c +1 -1
@@ -65,7 +65,7 @@ static ssize_t show_carrier(struct device *cdev,struct atm_dev *adev =to_atm_dev (cdev); pos +=sprintf (pos,"%d\n" , - adev->signal ==ATM_PHY_SIG_LOST ?0 :1 ); + adev->signal ==ATM_PHY_SIG_FOUND );return pos - buf; }
net/atm/resources.c +1 -1
@@ -38,7 +38,7 @@ static struct atm_dev *__alloc_atm_dev(const char *type)if (!dev)return NULL ; dev->type = type; - dev->signal =ATM_PHY_SIG_UNKNOWN ; + dev->signal =ATM_PHY_SIG_LOST ; dev->link_rate =ATM_OC3_PCR ;spin_lock_init (&dev->lock);INIT_LIST_HEAD (&dev->local);
Philippe De Muyter
Acked-byQuoted 14 lines · Chas Williams (CONTRACTOR)
Quoted 3 lines · In message <[email protected]>,Philippe De Muyter writes:
cxacru itself does the right thing : as soon as carrier state is known, signal is set to
ATM_PHY_SIG_LOSTorATM_PHY_SIG_FOUND, butatm_sysfs.c::show_carrieris wrong.so, i was thinking about something like this.
atm_dev->signalis initializated to_LOST(because it is at this point), but most drivers will set ->signal to_FOUNDsince they dont handle detecting carrier when they finish their hardware initialization. the usb atm layer is the major exception here, and it appears that they already handle theatm_dev->signalstatus correctly. the minor exception being "unknown line state" -- i am going to assume LOST is the best choice for this case.
Quoted 1 line
please try this and let me know if it fixes your problem.
I had replied on Sun, 21 Feb 2010 15:42:04 +0100
Did you push that patch, or a revised version of it, to Linus ?
Best regards
Philippe
Quoted 248 lines
drivers/atm/adummy.c +1
-0@@ -134,6 +134,7 @@ static int __init adummy_init(void) }list_add (&adummy_dev->entry, &adummy_devs); + atm_dev->signal =ATM_PHY_SIG_FOUND ; out:return err;drivers/atm/ambassador.c +1
-0@@ -2269,6 +2269,7 @@ static int __devinit amb_probe(struct pci_dev *pci_dev, const struct pci_device_// enable host interrupts interrupts_on (dev); + dev->atm_dev->signal =ATM_PHY_SIG_FOUND ; out:return err;drivers/atm/atmtcp.c +1
-0@@ -375,6 +375,7 @@ static int atmtcp_create(int itf,int persist,struct atm_dev **result) dev->dev_data = dev_data;PRIV (dev)->vcc =NULL ;PRIV (dev)->persist = persist; + dev->signal =ATM_PHY_SIG_FOUND ;if (result) *result = dev;return 0 ; }drivers/atm/firestream.c +1
-0@@ -1923,6 +1923,7 @@ static int __devinit firestream_init_one (struct pci_dev *pci_dev, fs_dev->next = fs_boards; fs_boards = fs_dev; + atm_dev->signal =ATM_PHY_SIG_FOUND ;return 0 ; err_out_free_atm_dev:drivers/atm/fore200e.c +1
-0@@ -2637,6 +2637,7 @@ fore200e_init(struct fore200e* fore200e)/* all done, board initialization is now complete */ fore200e->state =FORE200E_STATE_COMPLETE ; + fore200e->atm_dev->signal =ATM_PHY_SIG_FOUND ;return 0 ; }drivers/atm/he.c +2
-0@@ -1528,6 +1528,8 @@ he_start(struct atm_dev *dev)suni_init (he_dev->atm_dev);if (he_dev->atm_dev->phy && he_dev->atm_dev->phy->start) he_dev->atm_dev->phy->start (he_dev->atm_dev); +#else + he_dev->atm_dev->signal =ATM_PHY_SIG_FOUND ;#endif /* CONFIG_ATM_HE_USE_SUNI */ if (sdh) {drivers/atm/horizon.c +1
-0@@ -2827,6 +2827,7 @@ static int __devinit hrz_probe(struct pci_dev *pci_dev, const struct pci_device_ dev->housekeeping.data = (unsigned long ) dev;mod_timer (&dev->housekeeping, jiffies); + dev->atm_dev->signal =ATM_PHY_SIG_FOUND ; out:return err;drivers/atm/idt77252.c +2
-0@@ -3715,6 +3715,8 @@ idt77252_init_one(struct pci_dev *pcidev, const struct pci_device_id *id) err = -EIO ; goto err_out_deinit_card; } +#else + dev->signal =ATM_PHY_SIG_FOUND ;#endif /* CONFIG_ATM_IDT77252_USE_SUNI */ card->sramsize =probe_sram (card);drivers/atm/lanai.c +1
-0@@ -2250,6 +2250,7 @@ static int __devinit lanai_dev_open(struct atm_dev *atmdev)"board_rev=%d\n" , lanai->number, lanai->type==lanai2 ?"2" :"HB" , (unsigned int ) lanai->serialno, (unsigned int) lanai->serialno, lanai->board_rev); + atmdev->signal =ATM_PHY_SIG_FOUND ;return 0 ; error_vcctable:drivers/atm/nicstar.c +6
-2@@ -815,14 +815,18 @@ static int __devinit ns_init_card(int i, struct pci_dev *pcidev) card->atmdev->link_rate = card->max_pcr; card->atmdev->phy =NULL ; -#ifdef CONFIG_ATM_NICSTAR_USE_SUNI if (card->max_pcr == ATM_OC3_PCR) +#ifdef CONFIG_ATM_NICSTAR_USE_SUNI suni_init (card->atmdev); +#else + card->atmdev->signal =ATM_PHY_SIG_FOUND ;#endif /* CONFIG_ATM_NICSTAR_USE_SUNI */ -#ifdef CONFIG_ATM_NICSTAR_USE_IDT77105 if (card->max_pcr == ATM_25_PCR) +#ifdef CONFIG_ATM_NICSTAR_USE_IDT77105 idt77105_init (card->atmdev); +#else + card->atmdev->signal =ATM_PHY_SIG_FOUND ;#endif /* CONFIG_ATM_NICSTAR_USE_IDT77105 */ if (card->atmdev->phy && card->atmdev->phy->start)drivers/atm/solos-pci.c +1
-1@@ -1245,7 +1245,7 @@ static int atm_init(struct solos_card *card) card->atmdev[i]->ci_range.vci_bits =16 ; card->atmdev[i]->dev_data = card; card->atmdev[i]->phy_data = (void *)(unsigned long )i; - card->atmdev[i]->signal =ATM_PHY_SIG_UNKNOWN ; + card->atmdev[i]->signal =ATM_PHY_SIG_LOST ; skb =alloc_skb (sizeof (*header),GFP_ATOMIC );if (!skb) {drivers/atm/zatm.c +2
-0@@ -1345,6 +1345,8 @@ static int __devinit zatm_start(struct atm_dev *dev)zout (0xffffffff ,IMR );/* enable interrupts */ /* enable TX & RX */ zout (zin (GMR ) | uPD98401_GMR_SE | uPD98401_GMR_RE,GMR ); + + dev->signal =ATM_PHY_SIG_FOUND ; done:return error;drivers/usb/atm/cxacru.c +1
-1@@ -803,7 +803,7 @@ static void cxacru_poll_status(struct work_struct *work)break ;default : - atm_dev->signal =ATM_PHY_SIG_UNKNOWN ; + atm_dev->signal =ATM_PHY_SIG_LOST ;atm_info (usbatm,"Unknown line state %02x\n" , instance->line_status);break ; }drivers/usb/atm/speedtch.c +2
-2@@ -536,7 +536,7 @@ static void speedtch_check_status(struct work_struct *work)break ;case 0x08 : - atm_dev->signal =ATM_PHY_SIG_UNKNOWN ; + atm_dev->signal =ATM_PHY_SIG_LOST ;atm_info (usbatm,"ADSL line is blocked?\n" );break ;@@ -565,7 +565,7 @@ static void speedtch_check_status(struct work_struct *work)break ;default : - atm_dev->signal =ATM_PHY_SIG_UNKNOWN ; + atm_dev->signal =ATM_PHY_SIG_LOST ;atm_info (usbatm,"unknown line state %02x\n" , status);break ; }drivers/usb/atm/usbatm.c +1
-1@@ -963,7 +963,7 @@ static int usbatm_atm_init(struct usbatm_data *instance) atm_dev->ci_range.vpi_bits =ATM_CI_MAX ; atm_dev->ci_range.vci_bits =ATM_CI_MAX ; - atm_dev->signal =ATM_PHY_SIG_UNKNOWN ; + atm_dev->signal =ATM_PHY_SIG_LOST ;/* temp init ATM device, set to 128kbit */ atm_dev->link_rate =128 *1000 /424 ;include/linux/atmdev.h +0
-1@@ -290,7 +290,6 @@ enum {#define ATM_PHY_SIG_LOST 0/* no carrier/light */ -#define ATM_PHY_SIG_UNKNOWN 1/* carrier/light status is unknown */ #define ATM_PHY_SIG_FOUND 2/* carrier/light okay */ #define ATM_ATMOPT_CLP 1/* set CLP bit */ net/atm/atm_sysfs.c +1
-1@@ -65,7 +65,7 @@ static ssize_t show_carrier(struct device *cdev,struct atm_dev *adev =to_atm_dev (cdev); pos +=sprintf (pos,"%d\n" , - adev->signal ==ATM_PHY_SIG_LOST ?0 :1 ); + adev->signal ==ATM_PHY_SIG_FOUND );return pos - buf; }net/atm/resources.c +1
-1@@ -38,7 +38,7 @@ static struct atm_dev *__alloc_atm_dev(const char *type)if (!dev)return NULL ; dev->type = type; - dev->signal =ATM_PHY_SIG_UNKNOWN ; + dev->signal =ATM_PHY_SIG_LOST ; dev->link_rate =ATM_OC3_PCR ;spin_lock_init (&dev->lock);INIT_LIST_HEAD (&dev->local);