Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: msk(4) require to sync status buffer



Hi! tsutsui-san,


From: Izumi Tsutsui <tsutsui%ceres.dti.ne.jp@localhost>
Date: Mon, 10 Mar 2008 22:22:46 +0900

> > I tried variously today.  And, neither patch seems to be also appropriate.
> > For instance, I logged in other hosts with ssh(1) and executed 'ls -R /'.
> > The response died after it had operated for a while.  This msk(4) was not
> > able to be communicated after this.  X-<
> > 
> > Synchronous timing seems not to be correct yet.
> 
> Sorry, there is a botch in the previous one.

hmm...
Your patch seemed to be very good.  However, it did not work correctly in
my KURO-BOX/PRO.
Because the arm_pdcache_line_size of this CPU is 64.  And, the size of
struct msk_status_desc is eight bytes.

I propose to delay the clearness of flag SK_Y2_STOPC_OWN for a long time.


Thanks,
--
kiyohara


Index: if_msk.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/if_msk.c,v
retrieving revision 1.16
diff -u -r1.16 if_msk.c
--- if_msk.c    7 Feb 2008 01:21:56 -0000       1.16
+++ if_msk.c    15 Mar 2008 04:38:48 -0000
@@ -893,7 +893,10 @@
        /* Reset status ring. */
        bzero((char *)sc->sk_status_ring,
            MSK_STATUS_RING_CNT * sizeof(struct msk_status_desc));
+       bus_dmamap_sync(sc->sc_dmatag, sc->sk_status_map, 0,
+           sc->sk_status_map->dm_mapsize, BUS_DMASYNC_PREREAD);
        sc->sk_status_idx = 0;
+       sc->sk_status_own_idx = 0;
 
        sk_win_write_4(sc, SK_STAT_BMU_CSR, SK_STAT_BMU_RESET);
        sk_win_write_4(sc, SK_STAT_BMU_CSR, SK_STAT_BMU_UNRESET);
@@ -1256,8 +1259,6 @@
                goto fail_5;
        }
        sc->sk_status_ring = (struct msk_status_desc *)kva;
-       bzero(sc->sk_status_ring,
-           MSK_STATUS_RING_CNT * sizeof(struct msk_status_desc));
 
        /* Reset the adapter. */
        msk_reset(sc);
@@ -1741,11 +1742,12 @@
                if (sc_if->sk_cdata.sk_tx_cnt <= 0)
                        break;
                prog++;
+               cur_tx = &sc_if->sk_rdata->sk_tx_ring[cons];
+
                MSK_CDTXSYNC(sc_if, cons, 1,
                    BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE);
-
-               cur_tx = &sc_if->sk_rdata->sk_tx_ring[cons];
                sk_ctl = cur_tx->sk_ctl;
+               MSK_CDTXSYNC(sc_if, cons, 1, BUS_DMASYNC_PREREAD);
 #ifdef MSK_DEBUG
                if (mskdebug >= 2)
                        msk_dump_txdesc(cur_tx, cons);
@@ -1816,6 +1818,9 @@
        struct ifnet            *ifp0 = NULL, *ifp1 = NULL;
        int                     claimed = 0;
        u_int32_t               status;
+       uint32_t                st_status;
+       uint16_t                st_len;
+       uint8_t                 st_opcode, st_link;
        struct msk_status_desc  *cur_st;
 
        status = CSR_READ_4(sc, SK_Y2_ISSR2);
@@ -1841,42 +1846,56 @@
                msk_intr_yukon(sc_if1);
        }
 
-       MSK_CDSTSYNC(sc, sc->sk_status_idx,
-           BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE);
-       cur_st = &sc->sk_status_ring[sc->sk_status_idx];
+       for (;;) {
+               cur_st = &sc->sk_status_ring[sc->sk_status_idx];
+               MSK_CDSTSYNC(sc, sc->sk_status_idx,
+                   BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE);
+               st_opcode = cur_st->sk_opcode;
+               if ((st_opcode & SK_Y2_STOPC_OWN) == 0) {
+                       MSK_CDSTSYNC(sc, sc->sk_status_idx,
+                           BUS_DMASYNC_PREREAD);
+                       break;
+               }
+               st_status = le32toh(cur_st->sk_status);
+               st_len = le16toh(cur_st->sk_len);
+               st_link = cur_st->sk_link;
+               st_opcode &= ~SK_Y2_STOPC_OWN;
 
-       while (cur_st->sk_opcode & SK_Y2_STOPC_OWN) {
-               cur_st->sk_opcode &= ~SK_Y2_STOPC_OWN;
-               switch (cur_st->sk_opcode) {
+               switch (st_opcode) {
                case SK_Y2_STOPC_RXSTAT:
-                       msk_rxeof(sc->sk_if[cur_st->sk_link],
-                           letoh16(cur_st->sk_len),
-                           letoh32(cur_st->sk_status));
-                       SK_IF_WRITE_2(sc->sk_if[cur_st->sk_link], 0,
+                       msk_rxeof(sc->sk_if[st_link], st_len, st_status);
+                       SK_IF_WRITE_2(sc->sk_if[st_link], 0,
                            SK_RXQ1_Y2_PREF_PUTIDX,
-                           sc->sk_if[cur_st->sk_link]->sk_cdata.sk_rx_prod);
+                           sc->sk_if[st_link]->sk_cdata.sk_rx_prod);
                        break;
                case SK_Y2_STOPC_TXSTAT:
                        if (sc_if0)
-                               msk_txeof(sc_if0,
-                                   letoh32(cur_st->sk_status)
+                               msk_txeof(sc_if0, st_status
                                    & SK_Y2_ST_TXA1_MSKL);
                        if (sc_if1)
                                msk_txeof(sc_if1,
-                                   ((letoh32(cur_st->sk_status)
-                                       & SK_Y2_ST_TXA2_MSKL)
+                                   ((st_status & SK_Y2_ST_TXA2_MSKL)
                                        >> SK_Y2_ST_TXA2_SHIFTL)
-                                   | ((letoh16(cur_st->sk_len) & 
SK_Y2_ST_TXA2_MSKH) << SK_Y2_ST_TXA2_SHIFTH));
+                                   | ((st_len & SK_Y2_ST_TXA2_MSKH) << 
SK_Y2_ST_TXA2_SHIFTH));
                        break;
                default:
-                       aprint_error("opcode=0x%x\n", cur_st->sk_opcode);
+                       aprint_error("opcode=0x%x\n", st_opcode);
                        break;
                }
                SK_INC(sc->sk_status_idx, MSK_STATUS_RING_CNT);
+       }
+
+#define MSK_STATUS_RING_OWN_CNT(sc)                    \
+        (((sc)->sk_status_idx + MSK_STATUS_RING_CNT -  \
+                              (sc)->sk_status_own_idx) % MSK_STATUS_RING_CNT)
+
+       while (MSK_STATUS_RING_OWN_CNT(sc) > MSK_STATUS_RING_CNT / 2) {
+               cur_st = &sc->sk_status_ring[sc->sk_status_own_idx];
+               cur_st->sk_opcode &= ~SK_Y2_STOPC_OWN;
+               MSK_CDSTSYNC(sc, sc->sk_status_own_idx,
+                   BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
 
-               MSK_CDSTSYNC(sc, sc->sk_status_idx,
-                   BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE);
-               cur_st = &sc->sk_status_ring[sc->sk_status_idx];
+               SK_INC(sc->sk_status_own_idx, MSK_STATUS_RING_CNT);
        }
 
        if (status & SK_Y2_IMR_BMU) {
Index: if_mskvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/if_mskvar.h,v
retrieving revision 1.4
diff -u -r1.4 if_mskvar.h
--- if_mskvar.h 4 Mar 2007 06:02:22 -0000       1.4
+++ if_mskvar.h 15 Mar 2008 04:38:48 -0000
@@ -215,6 +215,7 @@
        struct msk_status_desc  *sk_status_ring;
        bus_dmamap_t            sk_status_map;
        int                     sk_status_idx;
+       int                     sk_status_own_idx;
 #if NRND > 0
        rndsource_element_t     rnd_source;
 #endif


Home | Main Index | Thread Index | Old Index