public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "ariga masahiro" <ariga@link-lab.co.jp>
To: "Gary Thomas" <gary@mlbassoc.com>,
	"Alok Singh" <alok.singh@broadcom.com>
Cc: <ecos-discuss@ecos.sourceware.org>
Subject: [ECOS] Can't Connect,TCP CHECKSUM INCORRECT
Date: Tue, 30 Oct 2007 02:41:00 -0000	[thread overview]
Message-ID: <000a01c81a9e$6b8c2240$1c0110ac@ariga> (raw)
In-Reply-To: <000301c816ab$6acbf7f0$1c0110ac@ariga>

[-- Attachment #1: Type: text/plain, Size: 5975 bytes --]

Hello,

I am the same person who sent the mailing list titled
"What functions should I call in ethernet drv ?".
At that time I was helped by your advices.
I was very much obliged.

I am sorry to say that I am encountered another trouble
and I ask you again your help.

Since then I continued to test transmission between host and target.
host(Client)  : 172.16.1.28  : nc_test_master
target(Server): 172.16.1.200 : nc_test_slave

UDP packets look like correctly transmitted between both terminals.

But when host tries to connect to target in TCP,
always happens connection error(timeout).
Below is host's output on cygwin shell.

$ ./nc_test_master.exe 172.16.1.200
Start Network Characterization - MASTER
================== No load, master at 100% ========================
Start TCP echo [64,10240] - no delays
Can't connect to slave: Connection refused
Can't connect to slave: Connection refused
Can't connect to slave: Connection refused

I sent also Etherreal packets captutre log file(text-gz format).
\TCP-checksum-log\DEBUG-00-prescale-20\EtherReal-log-txt\etherreal-TCP-2.txt
DEBUG=00,CYGHWR_HAL_SH_RTC_PRESCALE=20(CYGNUM_HAL_RTC_PERIOD=14745)
From here on,I refer to this file as er.txt.

When host send SYN packet to target(er.txt,line 89),
target tried to reply SYN-ACK but resulted [CHECKSUM INCORRECT].
Target's TCP packets almost always [CHECKSUM INCORRECT].
I also noticed Seq, Ack,and Win numbers all suspicious.
When Ack-number looks proper,CHECKSUM INCORRECT not occurs, but never 
connected.

I traced TCP checksum routine,and I am not sure they are correct.
I set break at 735 line in tcp_output() function in
packages\net\bsd_tcpip\current\src\sys\netinet\tcp_output.c

       730: #endif /* INET6 */
       731:       {
       732:     m->m_pkthdr.csum_flags = CSUM_TCP;
       733:     m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum);
       734:     if (len + optlen)
       735:         th->th_sum = in_addword(th->th_sum,
       736:             htons((u_short)(optlen + len)));
Then jumped to
packages\net\bsd_tcpip\current\src\sys\netinet\in_cksum.c(200): 
in_addword(u_short a, u_short b)

       199: u_short
       200: in_addword(u_short a, u_short b)
       201: {
       202:     u_int32_t sum = a + b;
       203:
       204:     ADDCARRY(sum);
       205:     return (sum);
       206: }

ADDCARRY is defined as below in in_cksum.c(76)

#define ADDCARRY(x)  (x > 65535 ? x -= 65535 : x)

Now this looks not doing one's complement sum for me.
Is this really correct function ?

Whereas in case of UDP checksum,
I set break at 735 line in udp_output() function in
packages\net\bsd_tcpip\current\src\sys\netinet\udp_usrreq.c(662)
udp_usrreq.c
       662: udp_output(inp, m, addr, control, p)

       731:     /*
       732:      * Set up checksum and output datagram.
       733:      */
       734:     if (udpcksum) {
       735:             ui->ui_sum = in_pseudo(ui->ui_src.s_addr, 
ui->ui_dst.s_addr,
       736:             htons((u_short)len + sizeof(struct udphdr) + 
IPPROTO_UDP));
       737:         m->m_pkthdr.csum_flags = CSUM_UDP;
       738:         m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum);
       739:     } else {
       740:         ui->ui_sum = 0;
       741:     }

And jumped to
       208: u_short
       209: in_pseudo(u_int32_t a, u_int32_t b, u_int32_t c)
       210: {
       211:     u_int64_t sum;
       212:     union q_util q_util;
       213:     union l_util l_util;
       214:
       215:     sum = (u_int64_t) a + b + c;
       216:     REDUCE16;
       217:     return (sum);
       218: }

#define REDUCE16         \
    {           \
 q_util.q = sum;         \
 l_util.l = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \
 sum = l_util.s[0] + l_util.s[1];      \
 ADDCARRY(sum);         \
    }

This looks like doing one's complement sum for me.

As Gary suggested,I checked hearbeat.
I changed CYGHWR_HAL_SH_RTC_PRESCALE from default 4 to 20 and
now,CYGNUM_HAL_RTC_PERIOD=14745,

cdl_option CYGNUM_HAL_RTC_PERIOD {
    # Flavor: data
    # No user value, uncomment the following line to provide one.
    # user_value 14745
    # value_source default
    # Default value: 
CYGHWR_HAL_SH_ONCHIP_PERIPHERAL_SPEED/CYGNUM_HAL_RTC_DENOMINATOR / 
CYGHWR_HAL_SH_RTC_PRESCALE
    #     CYGHWR_HAL_SH_ONCHIP_PERIPHERAL_SPEED == 29491200
    #     CYGNUM_HAL_RTC_DENOMINATOR == 100
    #     CYGHWR_HAL_SH_RTC_PRESCALE == 20
    #   --> 14745
};
but nothing changed.

Our most serious concern is, my concoction in driver source to accommodate 
to target's hardware pecuriality
is affecting those misbehaviour.
As I said in last mail, our company's target board was hardware wired to
retreive data in BigEndian.

I concocted in \packages\devs\eth\smsc\lan91cxx\current\src\if_lan91cxx.c.
cyg_uint8 get_data_byte(struct eth_drv_sc *sc)
{
    //20070919
    int sf;

    cyg_uint8 c;
    struct lan91cxx_priv_data *cpd =
        (struct lan91cxx_priv_data *)sc->driver_private;

    if( cpd->data_pos == sizeof(rxd_t) )
    {
        cpd->data_buf = get_data(sc);
        cpd->data_pos = 0;
        //20070919
        sf = 1;
    }
    //20070919 begin
    else{
        sf = 0;
  }
    //20070919 end

    //20070919 begin
//ORG    c = (cpd->data_buf>>(cpd->data_pos*8))&0xFF;
    c = (cpd->data_buf>>(sf*8))&0xFF;

    cpd->data_pos++;

    return c;
}
cyg_uint16 get_data_short(struct eth_drv_sc *sc)
{
    cyg_uint16 val;

    val = get_data_byte(sc);
//20071023
    //ORG val |= get_data_byte(sc)<<8;
    val = val<<8 | get_data_byte(sc);

    return CYG_LE16_TO_CPU(val);
}

I also send together target's serial log when I setted DEBUF=FF.
But if CYGNUM_HAL_RTC_PERIOD=14745 then happend time_out error at 
intialization(watchdog),
so I changed CYGHWR_HAL_SH_RTC_PRESCALE=4(CYGNUM_HAL_RTC_PERIOD=73728).
C:\cygwin\home\TCP-checksum-log\DEBUG-FF-prescale-4\Teraterm\MyFlashIDis422f9019.txt

I am perplexed what is happening,please help me.
Thanks in advance.

Masahiro Ariga 

[-- Attachment #2: TCP-checksum-log.tar.gz --]
[-- Type: application/x-gzip, Size: 13404 bytes --]

[-- Attachment #3: Type: text/plain, Size: 148 bytes --]

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

  reply	other threads:[~2007-10-30  2:41 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-14  5:37 [ECOS] Building error on CVS checkout sources ariga masahiro
2007-09-14  8:22 ` [ECOS] " Andrew Lunn
2007-09-14  9:38   ` [ECOS] Virtual Vector Configuration Stefan Sommerfeld
2007-09-14 10:17     ` Nick Garnett
2007-10-15  5:59   ` [ECOS] What functions should I call in ethernet drv ? ariga masahiro
2007-10-15 11:20     ` Gary Thomas
2007-10-16  3:04       ` ariga masahiro
2007-10-16 11:08         ` Gary Thomas
2007-10-17  7:41           ` ariga masahiro
2007-10-17 11:32             ` Gary Thomas
2007-10-18  7:17               ` ariga masahiro
     [not found]               ` <000c01c81151$9add59c0$1c0110ac@ariga>
2007-10-18 11:12                 ` Gary Thomas
2007-10-19  4:56                   ` ariga masahiro
2007-10-19  9:55                     ` Gary Thomas
2007-10-20  6:19                       ` ariga masahiro
2007-10-23  8:23                       ` ariga masahiro
2007-10-23  8:27                         ` Alok Singh
2007-10-23  9:05                           ` ariga masahiro
2007-10-25  2:05                           ` ariga masahiro
2007-10-30  2:41                             ` ariga masahiro [this message]
2007-10-30  3:02                               ` [ECOS] Can't Connect,TCP CHECKSUM INCORRECT Andrew Lunn
2007-10-30  4:17                               ` [ECOS] " Grant Edwards
2007-10-30  8:51                                 ` Alok Singh
2007-11-06  7:14                               ` [ECOS] " ariga masahiro
2007-11-06  7:58                                 ` Alok Singh
2007-11-06  8:30                                   ` ariga masahiro
2007-11-06  8:35                                     ` Andrew Lunn
2007-11-06 23:47                                       ` ariga masahiro
2007-11-07  1:05                                         ` ariga masahiro
2007-11-07  7:15                                           ` ariga masahiro
2007-11-07  8:24                                             ` ariga masahiro
2007-11-07 11:55                                               ` Alok Singh
2007-11-08  1:56                                               ` ariga masahiro
2007-11-08  8:23                                                 ` ariga masahiro
2007-11-09  1:25                                                   ` ariga masahiro
2007-11-13  1:13                                                     ` ariga masahiro
2007-11-16  7:40                                                       ` ariga masahiro
2007-11-08  9:13                                                 ` Alok Singh
2008-01-07  1:36                                       ` [ECOS] Wrongfully compiled code ariga masahiro
2007-10-17  8:45           ` [ECOS] What functions should I call in ethernet drv ? ariga masahiro

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='000a01c81a9e$6b8c2240$1c0110ac@ariga' \
    --to=ariga@link-lab.co.jp \
    --cc=alok.singh@broadcom.com \
    --cc=ecos-discuss@ecos.sourceware.org \
    --cc=gary@mlbassoc.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).