[PATCH 10/12] fsl/fman: Add FMan SP support

2015-06-10 Thread Igal . Liberman
From: Igal Liberman igal.liber...@freescale.com

Add Storage Profiles support.
The Storage Profiles contain parameters that are used by the FMan in
order to store frames being received on the Rx ports, or to
determine the parameters that affect writing the Internal Context
in the frame margin on Tx.

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 drivers/net/ethernet/freescale/fman/Makefile   |2 +
 drivers/net/ethernet/freescale/fman/fm_sp_common.h |  104 +
 drivers/net/ethernet/freescale/fman/sp/Makefile|3 +
 drivers/net/ethernet/freescale/fman/sp/fm_sp.c |  398 
 4 files changed, 507 insertions(+)
 create mode 100644 drivers/net/ethernet/freescale/fman/fm_sp_common.h
 create mode 100644 drivers/net/ethernet/freescale/fman/sp/Makefile
 create mode 100644 drivers/net/ethernet/freescale/fman/sp/fm_sp.c

diff --git a/drivers/net/ethernet/freescale/fman/Makefile 
b/drivers/net/ethernet/freescale/fman/Makefile
index f61d3a6..c6c3e24 100644
--- a/drivers/net/ethernet/freescale/fman/Makefile
+++ b/drivers/net/ethernet/freescale/fman/Makefile
@@ -8,3 +8,5 @@ fsl_fman-objs   := fman.o fm_muram.o fm.o fm_drv.o
 
 obj-y  += port/
 obj-y  += mac/
+obj-y  += sp/
+
diff --git a/drivers/net/ethernet/freescale/fman/fm_sp_common.h 
b/drivers/net/ethernet/freescale/fman/fm_sp_common.h
new file mode 100644
index 000..a99d795
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/fm_sp_common.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2008-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *   names of its contributors may be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License (GPL) as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* FM SP  ... */
+#ifndef __FM_SP_COMMON_H
+#define __FM_SP_COMMON_H
+
+#include service.h
+#include fm_ext.h
+#include fsl_fman.h
+
+/* defaults */
+#define DEFAULT_FM_SP_BUFFER_PREFIX_CONTENT_PRIV_DATA_SIZE  0
+#define DEFAULT_FM_SP_BUFFER_PREFIX_CONTENT_PRIV_PASS_PRS_RESULT false
+#define DEFAULT_FM_SP_BUFFER_PREFIX_CONTEXT_PASS_TIME_STAMP false
+#define DEFAULT_FM_SP_BUFFER_PREFIX_CONTEXT_DATA_ALIGN 64
+
+/* structure for defining internal context copying */
+struct fm_sp_int_context_data_copy_t {
+   /*  Offset in External buffer to which internal
+*  context is copied to (Rx) or taken from (Tx, Op).
+*/
+   uint16_t ext_buf_offset;
+   /* Offset within internal context to copy from
+* (Rx) or to copy to (Tx, Op).
+*/
+   uint8_t int_context_offset;
+   /* Internal offset size to be copied */
+   uint16_t size;
+};
+
+/*  struct for defining external buffer margins */
+struct fm_sp_buf_margins_t {
+   /* Number of bytes to be left at the beginning
+* of the external buffer (must be divisible by 16)
+*/
+   uint16_t start_margins;
+   /* number of bytes to be left at the end
+* of the external buffer(must be divisible by 16)
+*/
+   uint16_t end_margins;
+};
+
+struct fm_sp_buffer_offsets_t {
+   uint32_t data_offset;
+   uint32_t prs_result_offset;
+   uint32_t time_stamp_offset;
+   uint32_t hash_result_offset;
+};
+
+int fm_sp_build_buffer_structure(struct fm_sp_int_context_data_copy_t
+*p_fm_port_int_context_data_copy,
+struct 

[PATCH 10/12] fsl/fman: Add FMan SP support

2015-06-10 Thread Madalin Bucur
From: Igal Liberman igal.liber...@freescale.com

Add Storage Profiles support.
The Storage Profiles contain parameters that are used by the FMan in
order to store frames being received on the Rx ports, or to
determine the parameters that affect writing the Internal Context
in the frame margin on Tx.

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 drivers/net/ethernet/freescale/fman/Makefile   |   2 +
 drivers/net/ethernet/freescale/fman/fm_sp_common.h | 104 ++
 drivers/net/ethernet/freescale/fman/sp/Makefile|   3 +
 drivers/net/ethernet/freescale/fman/sp/fm_sp.c | 398 +
 4 files changed, 507 insertions(+)
 create mode 100644 drivers/net/ethernet/freescale/fman/fm_sp_common.h
 create mode 100644 drivers/net/ethernet/freescale/fman/sp/Makefile
 create mode 100644 drivers/net/ethernet/freescale/fman/sp/fm_sp.c

diff --git a/drivers/net/ethernet/freescale/fman/Makefile 
b/drivers/net/ethernet/freescale/fman/Makefile
index f61d3a6..c6c3e24 100644
--- a/drivers/net/ethernet/freescale/fman/Makefile
+++ b/drivers/net/ethernet/freescale/fman/Makefile
@@ -8,3 +8,5 @@ fsl_fman-objs   := fman.o fm_muram.o fm.o fm_drv.o
 
 obj-y  += port/
 obj-y  += mac/
+obj-y  += sp/
+
diff --git a/drivers/net/ethernet/freescale/fman/fm_sp_common.h 
b/drivers/net/ethernet/freescale/fman/fm_sp_common.h
new file mode 100644
index 000..a99d795
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/fm_sp_common.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2008-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *   names of its contributors may be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License (GPL) as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* FM SP  ... */
+#ifndef __FM_SP_COMMON_H
+#define __FM_SP_COMMON_H
+
+#include service.h
+#include fm_ext.h
+#include fsl_fman.h
+
+/* defaults */
+#define DEFAULT_FM_SP_BUFFER_PREFIX_CONTENT_PRIV_DATA_SIZE  0
+#define DEFAULT_FM_SP_BUFFER_PREFIX_CONTENT_PRIV_PASS_PRS_RESULT false
+#define DEFAULT_FM_SP_BUFFER_PREFIX_CONTEXT_PASS_TIME_STAMP false
+#define DEFAULT_FM_SP_BUFFER_PREFIX_CONTEXT_DATA_ALIGN 64
+
+/* structure for defining internal context copying */
+struct fm_sp_int_context_data_copy_t {
+   /*  Offset in External buffer to which internal
+*  context is copied to (Rx) or taken from (Tx, Op).
+*/
+   uint16_t ext_buf_offset;
+   /* Offset within internal context to copy from
+* (Rx) or to copy to (Tx, Op).
+*/
+   uint8_t int_context_offset;
+   /* Internal offset size to be copied */
+   uint16_t size;
+};
+
+/*  struct for defining external buffer margins */
+struct fm_sp_buf_margins_t {
+   /* Number of bytes to be left at the beginning
+* of the external buffer (must be divisible by 16)
+*/
+   uint16_t start_margins;
+   /* number of bytes to be left at the end
+* of the external buffer(must be divisible by 16)
+*/
+   uint16_t end_margins;
+};
+
+struct fm_sp_buffer_offsets_t {
+   uint32_t data_offset;
+   uint32_t prs_result_offset;
+   uint32_t time_stamp_offset;
+   uint32_t hash_result_offset;
+};
+
+int fm_sp_build_buffer_structure(struct fm_sp_int_context_data_copy_t
+*p_fm_port_int_context_data_copy,
+struct