Skip to contentSkip to conversation

PPPd ioctl, please help!

DISCUSSION rketcham 2 participants 4 messages May 9, 2008 PPP protocol drivers and compressors

lore
Share & tools
lore

rketcham

author
#0 lore raw

Hello,
I wrote a char driver to interface with an SPI chip which will be connected (via UART) to a cell modem. The SPI to UART chip works pretty well so far with custom software (I can send SMS messages for intance) but I'm having trouble with pppd (version 2.4.4) on the Gumstix distro.

My question is what are the ioctl commands (including the expected
responses) that I need to support in my driver. I have included what I
think are some of the ioctl commands into the driver and when they're called I have the driver print the variable name as defined in ioctls.h. The driver returns 0 unless it gets TCGETS at which point it returns the baud rate (B115200).

WRITE! -- pppd is writing to the driver
READ! -- pppd is reading from the driver
INTERRUPT --- New data has arrived from the modem to the SPI

Here's the driver and chat print out of when PPPd tries to connect to the internet via the SPI :

Dec 31 16:18:10 gumstix user.info kernel: Inserting the spi_uart module.
Dec 31 16:18:23 gumstix user.info kernel: PPP generic driver version 2.4.2
Dec 31 16:18:23 gumstix daemon.notice pppd[404]: pppd 2.4.4 started by root,
uid 0
Dec 31 16:18:23 gumstix user.info kernel: Device Open: 1
Dec 31 16:18:23 gumstix user.info kernel: The minor number: 0
Dec 31 16:18:23 gumstix user.info kernel: The device has been opened.
Dec 31 16:18:23 gumstix user.info kernel: TIOCMBIS
Dec 31 16:18:23 gumstix user.info kernel: TCGETS
Dec 31 16:18:23 gumstix user.info kernel: TCSETSF
Dec 31 16:18:23 gumstix user.info kernel: TCGETS
Dec 31 16:18:23 gumstix user.info kernel: TCGETS
Dec 31 16:18:23 gumstix user.info kernel: TCGETS
Dec 31 16:18:23 gumstix user.info kernel: TCGETS
Dec 31 16:18:23 gumstix user.info kernel: TCGETS
Dec 31 16:18:23 gumstix user.info kernel: TCSETS
Dec 31 16:18:23 gumstix user.info kernel: TCGETS
Dec 31 16:18:23 gumstix local2.info chat[406]: send (AT^M)
Dec 31 16:18:23 gumstix user.info kernel: WRITE!
Dec 31 16:18:23 gumstix user.info kernel: WRITE!
Dec 31 16:18:23 gumstix user.info kernel: INTERRUPT
Dec 31 16:18:23 gumstix user.info kernel: INTERRUPT
Dec 31 16:18:24 gumstix user.info kernel: Interrrupt from somewhere else.
Dec 31 16:18:24 gumstix user.warn kernel:
Dec 31 16:18:24 gumstix user.warn kernel: 15  14  13  12  11  10  9   8   7  
6   5   4   3   2   1   0
Dec 31 16:18:24 gumstix user.warn kernel: 1   1   1   1   1   1   1   1   1  
1   0   0   0   0   0   1
Dec 31 16:18:24 gumstix user.warn kernel:
Dec 31 16:18:24 gumstix user.info kernel: WRITE!
Dec 31 16:18:24 gumstix user.info kernel: INTERRUPT
Dec 31 16:18:24 gumstix user.info kernel: INTERRUPT
Dec 31 16:18:24 gumstix user.info kernel: Interrrupt from somewhere else.
Dec 31 16:18:24 gumstix user.warn kernel:
Dec 31 16:18:24 gumstix user.warn kernel: 15  14  13  12  11  10  9   8   7  
6   5   4   3   2   1   0
Dec 31 16:18:24 gumstix user.warn kernel: 1   1   1   1   1   1   1   1   1  
1   0   0   0   0   0   1
Dec 31 16:18:24 gumstix user.warn kernel:
Dec 31 16:18:24 gumstix local2.info chat[406]: expect (OK)
Dec 31 16:18:24 gumstix user.info kernel: READ!
Dec 31 16:18:24 gumstix user.info kernel: READ!
Dec 31 16:18:24 gumstix user.info kernel: READ!
Dec 31 16:18:24 gumstix user.info kernel: READ!
Dec 31 16:18:24 gumstix user.info kernel: READ!
Dec 31 16:18:24 gumstix local2.info chat[406]: AT^M^M
Dec 31 16:18:24 gumstix user.info kernel: READ!
Dec 31 16:18:24 gumstix user.info kernel: READ!
Dec 31 16:18:24 gumstix local2.info chat[406]: OK
Dec 31 16:18:24 gumstix local2.info chat[406]:  -- got it
Dec 31 16:18:24 gumstix local2.info chat[406]: send (ATD*99***1#^M)
Dec 31 16:18:24 gumstix user.info kernel: WRITE!
Dec 31 16:18:24 gumstix user.info kernel: WRITE!
Dec 31 16:18:24 gumstix user.info kernel: INTERRUPT
Dec 31 16:18:24 gumstix user.info kernel: INTERRUPT
Dec 31 16:18:24 gumstix user.info kernel: Interrrupt from somewhere else.
Dec 31 16:18:24 gumstix user.warn kernel:
Dec 31 16:18:24 gumstix user.warn kernel: 15  14  13  12  11  10  9   8   7  
6   5   4   3   2   1   0
Dec 31 16:18:24 gumstix user.warn kernel: 1   1   1   1   1   1   1   1   1  
1   0   0   0   0   0   1
Dec 31 16:18:24 gumstix user.warn kernel:
Dec 31 16:18:24 gumstix user.info kernel: WRITE!
Dec 31 16:18:24 gumstix user.info kernel: INTERRUPT
Dec 31 16:18:24 gumstix user.info kernel: WRITE!
Dec 31 16:18:24 gumstix user.info kernel: INTERRUPT
Dec 31 16:18:24 gumstix user.info kernel: WRITE!
Dec 31 16:18:24 gumstix user.info kernel: INTERRUPT
Dec 31 16:18:24 gumstix user.info kernel: WRITE!
Dec 31 16:18:24 gumstix user.info kernel: INTERRUPT
Dec 31 16:18:24 gumstix user.info kernel: WRITE!
Dec 31 16:18:24 gumstix user.info kernel: INTERRUPT
Dec 31 16:18:24 gumstix user.info kernel: WRITE!
Dec 31 16:18:24 gumstix user.info kernel: INTERRUPT
Dec 31 16:18:24 gumstix user.info kernel: WRITE!
Dec 31 16:18:24 gumstix user.info kernel: INTERRUPT
Dec 31 16:18:24 gumstix user.info kernel: WRITE!
Dec 31 16:18:24 gumstix user.info kernel: INTERRUPT
Dec 31 16:18:24 gumstix user.info kernel: WRITE!
Dec 31 16:18:24 gumstix user.info kernel: INTERRUPT
Dec 31 16:18:24 gumstix user.info kernel: WRITE!
Dec 31 16:18:24 gumstix user.info kernel: INTERRUPT
Dec 31 16:18:25 gumstix user.info kernel: INTERRUPT
Dec 31 16:18:25 gumstix user.info kernel: INTERRUPT
Dec 31 16:18:25 gumstix user.info kernel: Interrrupt from somewhere else.
Dec 31 16:18:25 gumstix user.warn kernel:
Dec 31 16:18:25 gumstix user.warn kernel: 15  14  13  12  11  10  9   8   7  
6   5   4   3   2   1   0
Dec 31 16:18:25 gumstix user.warn kernel: 1   1   1   1   1   1   1   1   1  
1   0   0   0   0   0   1
Dec 31 16:18:25 gumstix user.warn kernel:
Dec 31 16:18:24 gumstix local2.info chat[406]: expect (CONNECT)
Dec 31 16:18:25 gumstix user.info kernel: READ!
Dec 31 16:18:25 gumstix user.info kernel: READ!
Dec 31 16:18:25 gumstix local2.info chat[406]: ^M
Dec 31 16:18:25 gumstix user.info kernel: READ!
Dec 31 16:18:25 gumstix user.info kernel: READ!
Dec 31 16:18:25 gumstix user.info kernel: READ!
Dec 31 16:18:25 gumstix user.info kernel: READ!
Dec 31 16:18:25 gumstix user.info kernel: READ!
Dec 31 16:18:25 gumstix user.info kernel: READ!
Dec 31 16:18:25 gumstix user.info kernel: READ!
Dec 31 16:18:25 gumstix user.info kernel: READ!
Dec 31 16:18:25 gumstix user.info kernel: READ!
Dec 31 16:18:25 gumstix user.info kernel: READ!
Dec 31 16:18:25 gumstix user.info kernel: READ!
Dec 31 16:18:25 gumstix user.info kernel: READ!
Dec 31 16:18:25 gumstix user.info kernel: READ!
Dec 31 16:18:25 gumstix user.info kernel: READ!
Dec 31 16:18:25 gumstix local2.info chat[406]: ATD*99***1#^M^M
Dec 31 16:18:25 gumstix user.info kernel: READ!
Dec 31 16:18:25 gumstix user.info kernel: READ!
Dec 31 16:18:25 gumstix user.info kernel: READ!
Dec 31 16:18:25 gumstix user.info kernel: READ!
Dec 31 16:18:25 gumstix user.info kernel: READ!
Dec 31 16:18:25 gumstix user.info kernel: READ!
Dec 31 16:18:25 gumstix user.info kernel: READ!
Dec 31 16:18:25 gumstix local2.info chat[406]: CONNECT
Dec 31 16:18:25 gumstix local2.info chat[406]:  -- got it
Dec 31 16:18:25 gumstix local2.info chat[406]: send (dc^M)
Dec 31 16:18:25 gumstix user.info kernel: WRITE!
Dec 31 16:18:25 gumstix user.info kernel: WRITE!
Dec 31 16:18:25 gumstix user.info kernel: WRITE!
Dec 31 16:18:25 gumstix user.info kernel: TCSETS
Dec 31 16:18:25 gumstix user.info kernel: TCGETS
Dec 31 16:18:25 gumstix daemon.info pppd[404]: Serial connection
established.
Dec 31 16:18:25 gumstix user.info kernel: TIOCMBIS
Dec 31 16:18:25 gumstix user.info kernel: TCGETS
Dec 31 16:18:25 gumstix user.info kernel: TCSETSF
Dec 31 16:18:25 gumstix user.info kernel: TIOCEXCL
Dec 31 16:18:25 gumstix user.info kernel: TIOCSETD
Dec 31 16:18:25 gumstix user.info kernel: I don't know what the hell you
just sent... 0x80047437
Dec 31 16:18:25 gumstix daemon.err pppd[404]: Couldn't attach to channel 0:
No such device or address
Dec 31 16:18:25 gumstix user.info kernel: TIOCSETD
Dec 31 16:18:25 gumstix user.info kernel: TCSETSF
Dec 31 16:18:25 gumstix user.info kernel: The device has been closed.
Dec 31 16:18:25 gumstix daemon.info pppd[404]: Exit.

My pppd options are:
usepeerdns
defaultroute
noauth
local
hide-password
noipdefault
lcp-echo-interval 30
lcp-echo-failure 4

Thanks for your help!
Rich

Signature · 2 lines
View this message in context: http://www.nabble.com/PPPd-ioctl%2C-please-help%21-tp17153241p17153241.html
Sent from the linux-ppp mailing list archive at Nabble.com.
#1 lore raw
Quoted 3 lines · rketcham
Dec 31 16:18:25 gumstix user.info kernel: TIOCSETD
Dec 31 16:18:25 gumstix user.info kernel: I don't know what the hell you

just sent... 0x80047437

That last one looks to me like PPPIOCGCHAN. You're getting this because the TIOCSETD ioctl before it didn't set N_PPP mode.

Did you implement your new device on tty_io.c, or did you just break out in your own direction? If it's the latter (which is consistent with your other problems with ioctls), you might want to reconsider doing that.

But if not, then read through the tty subsystem and figure out what TIOCSETD does. You need to do the same.

Signature · 1 line
James Carlson         42.703N 71.076W         <[email protected]>
author
#2 lore raw
In reply to rketcham

Hey James,

Yea, this SPI driver was my first adventure into linux drivers so I may need you to lead me through some of this. When I first started I thought that a char driver would be exactly what I needed. Now it seems that I should have created a tty driver instead but I would rather try to get around that if it's possible and not too hard.

Given my limited experience in driver design would you recommend rewriting the driver as a tty driver (I'm guessing this would involve interfacing with tty_io.c) or is there another way? I was hoping to handle the ioctl myself. Would I need to include if_ppp.h?

Thanks,
Rich

Quoted 20 lines · James Carlson-2 wrote:

That last one looks to me like PPPIOCGCHAN. You're getting this because the TIOCSETD ioctl before it didn't set N_PPP mode.

Did you implement your new device on tty_io.c, or did you just break out in your own direction? If it's the latter (which is consistent with your other problems with ioctls), you might want to reconsider doing that.

But if not, then read through the tty subsystem and figure out what TIOCSETD does. You need to do the same.

Signature · 5 lines
James Carlson         42.703N 71.076W         <[email protected]>
--
To unsubscribe from this list: send the line "unsubscribe linux-ppp" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
View this message in context: http://www.nabble.com/PPPd-ioctl%2C-please-help%21-tp17153241p17154119.html
Sent from the linux-ppp mailing list archive at Nabble.com.
#3 lore raw
In reply to rketcham
Quoted 2 lines · rketcham

Yea, this SPI driver was my first adventure into linux drivers so I may need you to lead me through some of this.

I just diagnosed the problem; you should find someone with much more Linux tty driver experience to help you out.

Quoted 4 lines

When I first started I thought that a
char driver would be exactly what I needed. Now it seems that I should have created a tty driver instead but I would rather try to get around that if it's possible and not too hard.

I doubt that'd be very easy. You'd have to replicate most of what tty_io already does, and that seems fairly pointless and fragile. Any change to that subsystem will likely blow your driver's duplicate logic away.

Quoted 4 lines

Given my limited experience in driver design would you recommend rewriting the driver as a tty driver (I'm guessing this would involve interfacing with tty_io.c) or is there another way? I was hoping to handle the ioctl myself. Would I need to include if_ppp.h?

If it were mine, I'd take a look at one of the existing tty hardware drivers (drivers/serial/21285.c looks simple enough) and use that as a template.

Signature · 1 line
James Carlson         42.703N 71.076W         <[email protected]>