linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: David Miller <davem@davemloft.net>
Cc: ajk@comnets.uni-bremen.de, kuba@kernel.org,
	linux-hams@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: 6pack: Fix tx timeout and slot time
Date: Thu, 9 Sep 2021 07:53:29 -0700	[thread overview]
Message-ID: <751f5079-2da1-187e-573c-d7d2d6743bbf@roeck-us.net> (raw)
In-Reply-To: <20210909.123442.1648633411296774237.davem@davemloft.net>

On 9/9/21 4:34 AM, David Miller wrote:
> From: Guenter Roeck <linux@roeck-us.net>
> Date: Wed,  8 Sep 2021 20:57:43 -0700
> 
>> tx timeout and slot time are currently specified in units of HZ.
>> On Alpha, HZ is defined as 1024. When building alpha:allmodconfig,
>> this results in the following error message.
>>
>> drivers/net/hamradio/6pack.c: In function 'sixpack_open':
>> drivers/net/hamradio/6pack.c:71:41: error:
>> 	unsigned conversion from 'int' to 'unsigned char'
>> 	changes value from '256' to '0'
>>
>> In the 6PACK protocol, tx timeout is specified in units of 10 ms
>> and transmitted over the wire. Defining a value dependent on HZ
>> doesn't really make sense. Assume that the intent was to set tx
>> timeout and slot time based on a HZ value of 100 and use constants
>> instead of values depending on HZ for SIXP_TXDELAY and SIXP_SLOTTIME.
>>
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>> ---
>> No idea if this is correct or even makes sense. Compile tested only.
> 
> These are timer offsets so they have to me HZ based.  Better to make the
> structure members unsigned long, I think.
> 

Hmm, ok. Both tx_delay and slottime are updated in sp_encaps(), though,
from data in the transmit buffer. The KISS protocol description states
that the values are in units of 10ms; that is where my assumption
came from.

Command        Function         Comments
    0           Data frame       The  rest  of the frame is data to
                                 be sent on the HDLC channel.

    1           TXDELAY          The next  byte  is  the  transmitter
                                 keyup  delay  in  10 ms units.
                 		The default start-up value is 50
                                 (i.e., 500 ms).

    2           P                The next byte  is  the  persistence
                                 parameter,  p, scaled to the range
                                 0 - 255 with the following
                                 formula:

                                          P = p * 256 - 1

                                 The  default  value  is  P  =  63
                                 (i.e.,  p  =  0.25).

    3           SlotTime         The next byte is the slot interval
                                 in 10 ms units.
                                 The default is 10 (i.e., 100ms).

But then slottime is indeed used with jiffies, which is odd.

tx_delay is used (before it is updated) in encode_sixpack()
and added to a character buffer. I thought that was the value sent
on the wire (which would again be supposed to be in 10ms units).
I don't see where else it is used, but I may be missing it.
That means though it can not easily be changed to anything
but unsigned char.

Anyway, I am inclined to just mark the protocol as dependent on
!ALPHA. Would you accept that ?

Thanks,
Guenter

  reply	other threads:[~2021-09-09 14:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-09  3:57 [PATCH] net: 6pack: Fix tx timeout and slot time Guenter Roeck
2021-09-09 11:34 ` David Miller
2021-09-09 14:53   ` Guenter Roeck [this message]
2021-09-09 15:27     ` David Miller
2021-09-09 16:44       ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=751f5079-2da1-187e-573c-d7d2d6743bbf@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=ajk@comnets.uni-bremen.de \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-hams@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).