commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r7361 - in usrp2/trunk/firmware: apps include


From: eb
Subject: [Commit-gnuradio] r7361 - in usrp2/trunk/firmware: apps include
Date: Sat, 5 Jan 2008 13:04:18 -0700 (MST)

Author: eb
Date: 2008-01-05 13:04:17 -0700 (Sat, 05 Jan 2008)
New Revision: 7361

Added:
   usrp2/trunk/firmware/include/usrp2_mac_addr.h
Modified:
   usrp2/trunk/firmware/apps/app_common.c
   usrp2/trunk/firmware/apps/app_common.h
   usrp2/trunk/firmware/include/usrp2_eth_packet.h
Log:
removed unneeded copy from buffer to stack

Modified: usrp2/trunk/firmware/apps/app_common.c
===================================================================
--- usrp2/trunk/firmware/apps/app_common.c      2008-01-05 19:03:18 UTC (rev 
7360)
+++ usrp2/trunk/firmware/apps/app_common.c      2008-01-05 20:04:17 UTC (rev 
7361)
@@ -40,21 +40,18 @@
 }
 
 void
-handle_control_chan_frame(int bufno, u2_eth_packet_t *pkt, size_t len)
+handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len)
 {
-  static unsigned char payload[64] _AL4;
-  static unsigned char reply[sizeof(u2_eth_packet_t) + sizeof(u2_subpkt_t)] 
_AL4;
+  unsigned char reply[sizeof(u2_eth_packet_t) + sizeof(u2_subpkt_t)] _AL4;
   unsigned char *s = &reply[sizeof(u2_eth_packet_t)];
   size_t reply_len = 0;
   int   i;
 
-  // FIXME don't copy, we can byte address (read-only) in the buffer
-  // copy 64 bytes of payload into stack buffer
-  memcpy_wa(payload,
-                    (unsigned char *) buffer_ram(bufno) + 
sizeof(u2_eth_packet_t),
-                    sizeof(payload));
+  // point to beginning of payload (subpackets)
+  unsigned char *p = ((unsigned char *) pkt) + sizeof(u2_eth_packet_t);
 
-  unsigned char *p = payload;
+  // FIXME iterate over payload, handling more than a single subpacket
+
   int opcode = p[0];
 
   switch(opcode){
@@ -108,25 +105,21 @@
 bool
 eth_pkt_inspector(dbsm_t *sm, int bufno)
 {
-  u2_eth_packet_t pkt;
+  u2_eth_packet_t *pkt = (u2_eth_packet_t *) buffer_ram(bufno);
   size_t byte_len = (buffer_pool_status->last_line[bufno] - 1) * 4;
 
-  hal_toggle_leds(0x1);
+  // hal_toggle_leds(0x1);
 
   // inspect rcvd frame and figure out what do do.
 
-  // FIXME don't copy it in
-  // copy first part of frame to stack buffer so we can byte address it
-  memcpy_wa(&pkt, buffer_ram(bufno), sizeof(pkt));
-
-  if (pkt.ehdr.ethertype != U2_ETHERTYPE)
+  if (pkt->ehdr.ethertype != U2_ETHERTYPE)
     return true;       // ignore, probably bogus PAUSE frame from MAC
 
-  int chan = u2p_chan(&pkt.fixed);
+  int chan = u2p_chan(&pkt->fixed);
 
   switch (chan){
   case CONTROL_CHAN:
-    handle_control_chan_frame(bufno, &pkt, byte_len);
+    handle_control_chan_frame(pkt, byte_len);
     return true;       // we handled the packet
     break;
 

Modified: usrp2/trunk/firmware/apps/app_common.h
===================================================================
--- usrp2/trunk/firmware/apps/app_common.h      2008-01-05 19:03:18 UTC (rev 
7360)
+++ usrp2/trunk/firmware/apps/app_common.h      2008-01-05 20:04:17 UTC (rev 
7361)
@@ -33,7 +33,7 @@
 extern volatile bool link_is_up;       // eth handler sets this
 
 void set_reply_hdr(u2_eth_packet_t *reply_pkt, u2_eth_packet_t const *cmd_pkt);
-void handle_control_chan_frame(int bufno, u2_eth_packet_t *pkt, size_t len);
+//void handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len);
 
 /*
  * Called when an ethernet packet is received.

Modified: usrp2/trunk/firmware/include/usrp2_eth_packet.h
===================================================================
--- usrp2/trunk/firmware/include/usrp2_eth_packet.h     2008-01-05 19:03:18 UTC 
(rev 7360)
+++ usrp2/trunk/firmware/include/usrp2_eth_packet.h     2008-01-05 20:04:17 UTC 
(rev 7361)
@@ -21,7 +21,7 @@
 
 #include "usrp2_cdefs.h"
 #include "usrp2_bytesex.h"
-#include <stdint.h>
+#include "usrp2_mac_addr.h"
 
 __U2_BEGIN_DECLS
 
@@ -32,10 +32,6 @@
  * All these data structures are BIG-ENDIAN on the wire
  */
 
-typedef struct {
-  uint8_t      addr[6];
-} u2_mac_addr_t;
-
 /* The classic 14-byte ethernet header */
 
 typedef struct {
@@ -155,24 +151,28 @@
 /*
  * Opcodes for control channel
  */
-#define OP_ID                  0
-#define        OP_ID_REPLY             1
-#define        OP_PING_FIXED           2
-#define        OP_PING_FIXED_REPLY     3
-#define        OP_START_RX             4
-#define        OP_STOP_RX              5
-#define        OP_WRITE_REG            6
-#define        OP_WRITE_REG_MASKED     7
-#define        OP_READ_REG             8
-#define        OP_READ_REG_REPLY       9
+#define        OP_EOF                  0       // marks last subpacket in 
packet
+#define OP_ID                  1
+#define        OP_ID_REPLY             2
+#define        OP_START_RX             3
+#define        OP_STOP_RX              4
+#define        OP_WRITE_REG            5
+#define        OP_WRITE_REG_MASKED     6
+#define        OP_READ_REG             7
+#define        OP_READ_REG_REPLY       8
 
 typedef struct {
   uint8_t      opcode;
   uint8_t      len;
+  uint16_t     mbz;
+} op_eof_t;
+
+typedef struct {
+  uint8_t      opcode;
+  uint8_t      len;
   uint16_t     rid_mbz;
 } op_id_t;
 
-
 typedef struct {
   uint8_t      opcode;
   uint8_t      len;
@@ -190,6 +190,7 @@
   uint16_t     mbz;
 } op_start_rx_t;
 
+// FIXME move this into op_start_rx_t
 typedef struct {
   uint8_t      opcode;
   uint8_t      len;
@@ -208,13 +209,17 @@
 } op_stop_rx_t;
 
 
+// union of all of them
+
 typedef union {
-  op_id_t      op_id;
-  op_id_reply_t        op_id_reply;
-  op_start_rx_t        op_start_rx;
-  op_stop_rx_t op_stop_rx;
+  op_eof_t             op_eof;
+  op_id_t              op_id;
+  op_id_reply_t                op_id_reply;
+  op_start_rx_t                op_start_rx;
+  op_stop_rx_t         op_stop_rx;
 } u2_subpkt_t;
 
+
 __U2_END_DECLS
 
 #endif /* INCLUDED_USRP2_ETH_PACKET_H */

Added: usrp2/trunk/firmware/include/usrp2_mac_addr.h
===================================================================
--- usrp2/trunk/firmware/include/usrp2_mac_addr.h                               
(rev 0)
+++ usrp2/trunk/firmware/include/usrp2_mac_addr.h       2008-01-05 20:04:17 UTC 
(rev 7361)
@@ -0,0 +1,28 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef INCLUDED_USRP2_MAC_ADDR_H
+#define INCLUDED_USRP2_MAC_ADDR_H
+
+#include <stdint.h>
+
+typedef struct {
+  uint8_t      addr[6];
+} u2_mac_addr_t;
+
+#endif /* INCLUDED_USRP2_MAC_ADDR_H */


Property changes on: usrp2/trunk/firmware/include/usrp2_mac_addr.h
___________________________________________________________________
Name: svn:eol-style
   + native





reply via email to

[Prev in Thread] Current Thread [Next in Thread]