Commit 01d04936 authored by Stefan Chulski's avatar Stefan Chulski Committed by David S. Miller

net: mvpp2: use the same buffer pool for all ports

This patch configures the buffer manager long pool for all ports part of
the same CP. Long pool separation between ports is redundant since there
are no performance improvement when different pools are used.
Signed-off-by: default avatarStefan Chulski <stefanc@marvell.com>
[Antoine: cosmetic cleanup, commit message]
Signed-off-by: default avatarAntoine Tenart <antoine.tenart@bootlin.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8eb1a859
...@@ -808,23 +808,23 @@ enum mvpp2_prs_l3_cast { ...@@ -808,23 +808,23 @@ enum mvpp2_prs_l3_cast {
#define MVPP22_RSS_TABLE_ENTRIES 32 #define MVPP22_RSS_TABLE_ENTRIES 32
/* BM constants */ /* BM constants */
#define MVPP2_BM_POOLS_NUM 8
#define MVPP2_BM_LONG_BUF_NUM 1024 #define MVPP2_BM_LONG_BUF_NUM 1024
#define MVPP2_BM_SHORT_BUF_NUM 2048 #define MVPP2_BM_SHORT_BUF_NUM 2048
#define MVPP2_BM_POOL_SIZE_MAX (16*1024 - MVPP2_BM_POOL_PTR_ALIGN/4) #define MVPP2_BM_POOL_SIZE_MAX (16*1024 - MVPP2_BM_POOL_PTR_ALIGN/4)
#define MVPP2_BM_POOL_PTR_ALIGN 128 #define MVPP2_BM_POOL_PTR_ALIGN 128
#define MVPP2_BM_SWF_LONG_POOL(port) ((port > 2) ? 2 : port)
#define MVPP2_BM_SWF_SHORT_POOL 3
/* BM cookie (32 bits) definition */ /* BM cookie (32 bits) definition */
#define MVPP2_BM_COOKIE_POOL_OFFS 8 #define MVPP2_BM_COOKIE_POOL_OFFS 8
#define MVPP2_BM_COOKIE_CPU_OFFS 24 #define MVPP2_BM_COOKIE_CPU_OFFS 24
#define MVPP2_BM_SHORT_FRAME_SIZE 512
#define MVPP2_BM_LONG_FRAME_SIZE 2048
/* BM short pool packet size /* BM short pool packet size
* These value assure that for SWF the total number * These value assure that for SWF the total number
* of bytes allocated for each buffer will be 512 * of bytes allocated for each buffer will be 512
*/ */
#define MVPP2_BM_SHORT_PKT_SIZE MVPP2_RX_MAX_PKT_SIZE(512) #define MVPP2_BM_SHORT_PKT_SIZE MVPP2_RX_MAX_PKT_SIZE(MVPP2_BM_SHORT_FRAME_SIZE)
#define MVPP2_BM_LONG_PKT_SIZE MVPP2_RX_MAX_PKT_SIZE(MVPP2_BM_LONG_FRAME_SIZE)
#define MVPP21_ADDR_SPACE_SZ 0 #define MVPP21_ADDR_SPACE_SZ 0
#define MVPP22_ADDR_SPACE_SZ SZ_64K #define MVPP22_ADDR_SPACE_SZ SZ_64K
...@@ -832,12 +832,17 @@ enum mvpp2_prs_l3_cast { ...@@ -832,12 +832,17 @@ enum mvpp2_prs_l3_cast {
#define MVPP2_MAX_THREADS 8 #define MVPP2_MAX_THREADS 8
#define MVPP2_MAX_QVECS MVPP2_MAX_THREADS #define MVPP2_MAX_QVECS MVPP2_MAX_THREADS
enum mvpp2_bm_type { enum mvpp2_bm_pool_log_num {
MVPP2_BM_FREE, MVPP2_BM_SHORT,
MVPP2_BM_SWF_LONG, MVPP2_BM_LONG,
MVPP2_BM_SWF_SHORT MVPP2_BM_POOLS_NUM
}; };
static struct {
int pkt_size;
int buf_num;
} mvpp2_pools[MVPP2_BM_POOLS_NUM];
/* GMAC MIB Counters register definitions */ /* GMAC MIB Counters register definitions */
#define MVPP21_MIB_COUNTERS_OFFSET 0x1000 #define MVPP21_MIB_COUNTERS_OFFSET 0x1000
#define MVPP21_MIB_COUNTERS_PORT_SZ 0x400 #define MVPP21_MIB_COUNTERS_PORT_SZ 0x400
...@@ -1266,7 +1271,6 @@ struct mvpp2_cls_lookup_entry { ...@@ -1266,7 +1271,6 @@ struct mvpp2_cls_lookup_entry {
struct mvpp2_bm_pool { struct mvpp2_bm_pool {
/* Pool number in the range 0-7 */ /* Pool number in the range 0-7 */
int id; int id;
enum mvpp2_bm_type type;
/* Buffer Pointers Pool External (BPPE) size */ /* Buffer Pointers Pool External (BPPE) size */
int size; int size;
...@@ -4195,7 +4199,6 @@ static int mvpp2_bm_pool_create(struct platform_device *pdev, ...@@ -4195,7 +4199,6 @@ static int mvpp2_bm_pool_create(struct platform_device *pdev,
val |= MVPP2_BM_START_MASK; val |= MVPP2_BM_START_MASK;
mvpp2_write(priv, MVPP2_BM_POOL_CTRL_REG(bm_pool->id), val); mvpp2_write(priv, MVPP2_BM_POOL_CTRL_REG(bm_pool->id), val);
bm_pool->type = MVPP2_BM_FREE;
bm_pool->size = size; bm_pool->size = size;
bm_pool->pkt_size = 0; bm_pool->pkt_size = 0;
bm_pool->buf_num = 0; bm_pool->buf_num = 0;
...@@ -4345,6 +4348,17 @@ static int mvpp2_bm_init(struct platform_device *pdev, struct mvpp2 *priv) ...@@ -4345,6 +4348,17 @@ static int mvpp2_bm_init(struct platform_device *pdev, struct mvpp2 *priv)
return 0; return 0;
} }
static void mvpp2_setup_bm_pool(void)
{
/* Short pool */
mvpp2_pools[MVPP2_BM_SHORT].buf_num = MVPP2_BM_SHORT_BUF_NUM;
mvpp2_pools[MVPP2_BM_SHORT].pkt_size = MVPP2_BM_SHORT_PKT_SIZE;
/* Long pool */
mvpp2_pools[MVPP2_BM_LONG].buf_num = MVPP2_BM_LONG_BUF_NUM;
mvpp2_pools[MVPP2_BM_LONG].pkt_size = MVPP2_BM_LONG_PKT_SIZE;
}
/* Attach long pool to rxq */ /* Attach long pool to rxq */
static void mvpp2_rxq_long_pool_set(struct mvpp2_port *port, static void mvpp2_rxq_long_pool_set(struct mvpp2_port *port,
int lrxq, int long_pool) int lrxq, int long_pool)
...@@ -4483,13 +4497,11 @@ static int mvpp2_bm_bufs_add(struct mvpp2_port *port, ...@@ -4483,13 +4497,11 @@ static int mvpp2_bm_bufs_add(struct mvpp2_port *port,
bm_pool->buf_num += i; bm_pool->buf_num += i;
netdev_dbg(port->dev, netdev_dbg(port->dev,
"%s pool %d: pkt_size=%4d, buf_size=%4d, total_size=%4d\n", "pool %d: pkt_size=%4d, buf_size=%4d, total_size=%4d\n",
bm_pool->type == MVPP2_BM_SWF_SHORT ? "short" : " long",
bm_pool->id, bm_pool->pkt_size, buf_size, total_size); bm_pool->id, bm_pool->pkt_size, buf_size, total_size);
netdev_dbg(port->dev, netdev_dbg(port->dev,
"%s pool %d: %d of %d buffers added\n", "pool %d: %d of %d buffers added\n",
bm_pool->type == MVPP2_BM_SWF_SHORT ? "short" : " long",
bm_pool->id, i, buf_num); bm_pool->id, i, buf_num);
return i; return i;
} }
...@@ -4498,25 +4510,20 @@ static int mvpp2_bm_bufs_add(struct mvpp2_port *port, ...@@ -4498,25 +4510,20 @@ static int mvpp2_bm_bufs_add(struct mvpp2_port *port,
* pool pointer on success * pool pointer on success
*/ */
static struct mvpp2_bm_pool * static struct mvpp2_bm_pool *
mvpp2_bm_pool_use(struct mvpp2_port *port, int pool, enum mvpp2_bm_type type, mvpp2_bm_pool_use(struct mvpp2_port *port, unsigned pool, int pkt_size)
int pkt_size)
{ {
struct mvpp2_bm_pool *new_pool = &port->priv->bm_pools[pool]; struct mvpp2_bm_pool *new_pool = &port->priv->bm_pools[pool];
int num; int num;
if (new_pool->type != MVPP2_BM_FREE && new_pool->type != type) { if (pool >= MVPP2_BM_POOLS_NUM) {
netdev_err(port->dev, "mixing pool types is forbidden\n"); netdev_err(port->dev, "Invalid pool %d\n", pool);
return NULL; return NULL;
} }
if (new_pool->type == MVPP2_BM_FREE)
new_pool->type = type;
/* Allocate buffers in case BM pool is used as long pool, but packet /* Allocate buffers in case BM pool is used as long pool, but packet
* size doesn't match MTU or BM pool hasn't being used yet * size doesn't match MTU or BM pool hasn't being used yet
*/ */
if (((type == MVPP2_BM_SWF_LONG) && (pkt_size > new_pool->pkt_size)) || if (new_pool->pkt_size == 0) {
(new_pool->pkt_size == 0)) {
int pkts_num; int pkts_num;
/* Set default buffer number or free all the buffers in case /* Set default buffer number or free all the buffers in case
...@@ -4524,9 +4531,7 @@ mvpp2_bm_pool_use(struct mvpp2_port *port, int pool, enum mvpp2_bm_type type, ...@@ -4524,9 +4531,7 @@ mvpp2_bm_pool_use(struct mvpp2_port *port, int pool, enum mvpp2_bm_type type,
*/ */
pkts_num = new_pool->buf_num; pkts_num = new_pool->buf_num;
if (pkts_num == 0) if (pkts_num == 0)
pkts_num = type == MVPP2_BM_SWF_LONG ? pkts_num = mvpp2_pools[pool].buf_num;
MVPP2_BM_LONG_BUF_NUM :
MVPP2_BM_SHORT_BUF_NUM;
else else
mvpp2_bm_bufs_free(port->dev->dev.parent, mvpp2_bm_bufs_free(port->dev->dev.parent,
port->priv, new_pool); port->priv, new_pool);
...@@ -4558,9 +4563,8 @@ static int mvpp2_swf_bm_pool_init(struct mvpp2_port *port) ...@@ -4558,9 +4563,8 @@ static int mvpp2_swf_bm_pool_init(struct mvpp2_port *port)
if (!port->pool_long) { if (!port->pool_long) {
port->pool_long = port->pool_long =
mvpp2_bm_pool_use(port, MVPP2_BM_SWF_LONG_POOL(port->id), mvpp2_bm_pool_use(port, MVPP2_BM_LONG,
MVPP2_BM_SWF_LONG, mvpp2_pools[MVPP2_BM_LONG].pkt_size);
port->pkt_size);
if (!port->pool_long) if (!port->pool_long)
return -ENOMEM; return -ENOMEM;
...@@ -4572,9 +4576,8 @@ static int mvpp2_swf_bm_pool_init(struct mvpp2_port *port) ...@@ -4572,9 +4576,8 @@ static int mvpp2_swf_bm_pool_init(struct mvpp2_port *port)
if (!port->pool_short) { if (!port->pool_short) {
port->pool_short = port->pool_short =
mvpp2_bm_pool_use(port, MVPP2_BM_SWF_SHORT_POOL, mvpp2_bm_pool_use(port, MVPP2_BM_SHORT,
MVPP2_BM_SWF_SHORT, mvpp2_pools[MVPP2_BM_SHORT].pkt_size);
MVPP2_BM_SHORT_PKT_SIZE);
if (!port->pool_short) if (!port->pool_short)
return -ENOMEM; return -ENOMEM;
...@@ -4593,7 +4596,6 @@ static int mvpp2_bm_update_mtu(struct net_device *dev, int mtu) ...@@ -4593,7 +4596,6 @@ static int mvpp2_bm_update_mtu(struct net_device *dev, int mtu)
struct mvpp2_port *port = netdev_priv(dev); struct mvpp2_port *port = netdev_priv(dev);
struct mvpp2_bm_pool *port_pool = port->pool_long; struct mvpp2_bm_pool *port_pool = port->pool_long;
int num, pkts_num = port_pool->buf_num; int num, pkts_num = port_pool->buf_num;
int pkt_size = MVPP2_RX_PKT_SIZE(mtu);
/* Update BM pool with new buffer size */ /* Update BM pool with new buffer size */
mvpp2_bm_bufs_free(dev->dev.parent, port->priv, port_pool); mvpp2_bm_bufs_free(dev->dev.parent, port->priv, port_pool);
...@@ -4602,18 +4604,12 @@ static int mvpp2_bm_update_mtu(struct net_device *dev, int mtu) ...@@ -4602,18 +4604,12 @@ static int mvpp2_bm_update_mtu(struct net_device *dev, int mtu)
return -EIO; return -EIO;
} }
port_pool->pkt_size = pkt_size;
port_pool->frag_size = SKB_DATA_ALIGN(MVPP2_RX_BUF_SIZE(pkt_size)) +
MVPP2_SKB_SHINFO_SIZE;
num = mvpp2_bm_bufs_add(port, port_pool, pkts_num); num = mvpp2_bm_bufs_add(port, port_pool, pkts_num);
if (num != pkts_num) { if (num != pkts_num) {
WARN(1, "pool %d: %d of %d allocated\n", WARN(1, "pool %d: %d of %d allocated\n",
port_pool->id, num, pkts_num); port_pool->id, num, pkts_num);
return -EIO; return -EIO;
} }
mvpp2_bm_pool_bufsize_set(port->priv, port_pool,
MVPP2_RX_BUF_SIZE(port_pool->pkt_size));
dev->mtu = mtu; dev->mtu = mtu;
netdev_update_features(dev); netdev_update_features(dev);
return 0; return 0;
...@@ -8630,6 +8626,8 @@ static int mvpp2_probe(struct platform_device *pdev) ...@@ -8630,6 +8626,8 @@ static int mvpp2_probe(struct platform_device *pdev)
priv->sysctrl_base = NULL; priv->sysctrl_base = NULL;
} }
mvpp2_setup_bm_pool();
for (i = 0; i < MVPP2_MAX_THREADS; i++) { for (i = 0; i < MVPP2_MAX_THREADS; i++) {
u32 addr_space_sz; u32 addr_space_sz;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment