Changeset 66c9481 in rtems-libbsd
- Timestamp:
- 01/15/19 06:56:36 (5 years ago)
- Branches:
- 5-freebsd-12, 6-freebsd-12
- Children:
- aec8db0
- Parents:
- 06e155a
- git-author:
- Sebastian Huber <sebastian.huber@…> (01/15/19 06:56:36)
- git-committer:
- Sebastian Huber <sebastian.huber@…> (01/21/19 08:35:06)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
rtemsbsd/sys/powerpc/drivers/net/ethernet/freescale/dpaa/if_fmanmac.c
r06e155a r66c9481 114 114 } 115 115 116 static void 117 fman_mac_txstart_locked(struct ifnet *ifp, struct fman_mac_softc *sc) 118 { 119 120 FMAN_MAC_ASSERT_LOCKED(sc); 121 122 for (;;) { 123 struct fman_mac_sgt *sgt; 124 struct mbuf *m; 125 struct mbuf *n; 126 struct qm_fd fd; 127 struct dpaa_priv *priv; 128 struct qman_fq *egress_fq; 129 int queue = 0; 130 size_t i; 131 int err; 132 133 IFQ_DRV_DEQUEUE(&ifp->if_snd, m); 134 if (m == NULL) { 135 break; 136 } 137 138 sgt = uma_zalloc(fman_mac_sgt_zone, M_NOWAIT); 139 if (sgt == NULL) { 116 static int 117 fman_mac_tx(struct ifnet *ifp, struct mbuf *m) 118 { 119 struct fman_mac_softc *sc; 120 struct fman_mac_sgt *sgt; 121 struct mbuf *n; 122 struct qm_fd fd; 123 struct dpaa_priv *priv; 124 struct qman_fq *egress_fq; 125 int queue = 0; 126 size_t i; 127 int err; 128 129 sc = ifp->if_softc; 130 131 sgt = uma_zalloc(fman_mac_sgt_zone, M_NOWAIT); 132 if (unlikely(sgt == NULL)) { 133 if_inc_counter(ifp, IFCOUNTER_OQDROPS, 1); 134 m_freem(m); 135 return (ENOBUFS); 136 } 137 138 qm_fd_clear_fd(&fd); 139 qm_fd_set_sg(&fd, offsetof(struct fman_mac_sgt, sg), m->m_pkthdr.len); 140 fd.bpid = FSL_DPAA_BPID_INV; 141 fd.cmd |= cpu_to_be32(FM_FD_CMD_FCO); 142 qm_fd_addr_set64(&fd, (uintptr_t)sgt); 143 fman_mac_enable_tx_csum(m, &fd, &sgt->prs); 144 145 repeat_with_collapsed_mbuf_chain: 146 147 i = 0; 148 n = m; 149 150 while (n != NULL && i < DPAA_SGT_MAX_ENTRIES) { 151 int len = n->m_len; 152 153 if (len > 0) { 154 qm_sg_entry_set_len(&sgt->sg[i], len); 155 sgt->sg[i].bpid = FSL_DPAA_BPID_INV; 156 sgt->sg[i].offset = 0; 157 qm_sg_entry_set64(&sgt->sg[i], 158 mtod(n, uintptr_t)); 159 ++i; 160 } 161 162 n = n->m_next; 163 } 164 165 if (unlikely(n != NULL && i == DPAA_SGT_MAX_ENTRIES)) { 166 struct mbuf *c; 167 168 c = m_collapse(m, M_NOWAIT, DPAA_SGT_MAX_ENTRIES); 169 if (c == NULL) { 140 170 if_inc_counter(ifp, IFCOUNTER_OQDROPS, 1); 141 171 m_freem(m); 142 continue; 143 } 144 145 qm_fd_clear_fd(&fd); 146 qm_fd_set_sg(&fd, offsetof(struct fman_mac_sgt, sg), m->m_pkthdr.len); 147 fd.bpid = FSL_DPAA_BPID_INV; 148 fd.cmd |= cpu_to_be32(FM_FD_CMD_FCO); 149 qm_fd_addr_set64(&fd, (uintptr_t)sgt); 150 fman_mac_enable_tx_csum(m, &fd, &sgt->prs); 151 152 repeat_with_collapsed_mbuf_chain: 153 154 i = 0; 155 n = m; 156 157 while (n != NULL && i < DPAA_SGT_MAX_ENTRIES) { 158 int len = n->m_len; 159 160 if (len > 0) { 161 qm_sg_entry_set_len(&sgt->sg[i], len); 162 sgt->sg[i].bpid = FSL_DPAA_BPID_INV; 163 sgt->sg[i].offset = 0; 164 qm_sg_entry_set64(&sgt->sg[i], 165 mtod(n, uintptr_t)); 166 ++i; 167 } 168 169 n = n->m_next; 170 } 171 172 if (n != NULL && i == DPAA_SGT_MAX_ENTRIES) { 173 struct mbuf *c; 174 175 c = m_collapse(m, M_NOWAIT, DPAA_SGT_MAX_ENTRIES); 176 if (c == NULL) { 177 if_inc_counter(ifp, IFCOUNTER_OQDROPS, 1); 178 m_freem(m); 179 uma_zfree(fman_mac_sgt_zone, sgt); 180 continue; 181 } 182 183 m = c; 184 goto repeat_with_collapsed_mbuf_chain; 185 } 186 187 sgt->sg[i - 1].cfg |= cpu_to_be32(QM_SG_FIN); 188 sgt->m = m; 189 priv = netdev_priv(&sc->mac_dev.net_dev); 190 egress_fq = priv->egress_fqs[queue]; 191 fd.cmd |= cpu_to_be32(qman_fq_fqid(priv->conf_fqs[queue])); 192 193 for (i = 0; i < DPAA_ENQUEUE_RETRIES; ++i) { 194 err = qman_enqueue(egress_fq, &fd); 195 if (err != -EBUSY) { 196 break; 197 } 198 } 199 200 if (unlikely(err < 0)) { 201 if_inc_counter(ifp, IFCOUNTER_OQDROPS, 1); 202 m_freem(m); 203 continue; 204 } 205 } 206 } 207 208 static void 209 fman_mac_txstart(struct ifnet *ifp) 210 { 211 struct fman_mac_softc *sc; 212 213 sc = ifp->if_softc; 214 215 FMAN_MAC_LOCK(sc); 216 fman_mac_txstart_locked(ifp, sc); 217 FMAN_MAC_UNLOCK(sc); 172 uma_zfree(fman_mac_sgt_zone, sgt); 173 return (ENOBUFS); 174 } 175 176 m = c; 177 goto repeat_with_collapsed_mbuf_chain; 178 } 179 180 sgt->sg[i - 1].cfg |= cpu_to_be32(QM_SG_FIN); 181 sgt->m = m; 182 priv = netdev_priv(&sc->mac_dev.net_dev); 183 egress_fq = priv->egress_fqs[queue]; 184 fd.cmd |= cpu_to_be32(qman_fq_fqid(priv->conf_fqs[queue])); 185 186 for (i = 0; i < DPAA_ENQUEUE_RETRIES; ++i) { 187 err = qman_enqueue(egress_fq, &fd); 188 if (likely(err != -EBUSY)) { 189 break; 190 } 191 } 192 193 if (unlikely(err < 0)) { 194 if_inc_counter(ifp, IFCOUNTER_OQDROPS, 1); 195 m_freem(m); 196 return (ENOBUFS); 197 } 198 199 return (0); 218 200 } 219 201 … … 448 430 ifp->if_capenable = ifp->if_capabilities; 449 431 ifp->if_hwassist = FMAN_MAC_CSUM; 450 ifp->if_start = fman_mac_txstart; 432 ifp->if_transmit = fman_mac_tx; 433 ifp->if_qflush = if_qflush; 451 434 ifp->if_ioctl = fman_mac_ioctl; 452 435 ifp->if_init = fman_mac_init;
Note: See TracChangeset
for help on using the changeset viewer.